dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
static int findLongestRepeatingSubSeq ( String str ) { int n = str . Length ; int [ , ] dp = new int [ n + 1 , n + 1 ] ; for ( int i = 0 ; i <= n ; i ++ ) for ( int j = 0 ; j <= n ; j ++ ) dp [ i , j ] = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = 1 ; j <= n ; j ++ ) { if ( str [ i - 1 ] == str [ j - 1 ] && i != j ) dp [ i , j ] = 1 + dp [ i - 1 , j - 1 ] ; else dp [ i , j ] = Math . Max ( dp [ i , j - 1 ] , dp [ i - 1 , j ] ) ; } } return dp [ n , n ] ; }

Accumulator variables: i, j
Iterator variables: i, j
C# program:
using System ; class GFG { static int waysToArrange ( int N , int K , int [ ] k ) { int [ , ] C = new int [ N + 1 , N + 1 ] ; int i , j ; for ( i = 0 ; i <= N ; i ++ ) { for ( j = 0 ; j <= i ; j ++ ) { if ( j == 0 j == i ) C [ i , j ] = 1 ; else C [ i , j ] = ( C [ i - 1 , j - 1 ] + C [ i - 1 , j ] ) ; } } int [ ] dp = new int [ K + 1 ] ; int count = 0 ; dp [ 0 ] = 1 ; for ( i = 0 ; i < K ; i ++ ) { dp [ i + 1 ] = ( dp [ i ] * C [ count + k [ i ] - 1 , k [ i ] - 1 ] ) ; count += k [ i ] ; } return dp [ K ] ; } static void Main ( ) { int N = 4 ; int [ ] k = new int [ ] { 2 , 2 } ; int K = k . Length ; Console . Write ( waysToArrange ( N , K , k ) ) ; } }

Index/key variables: K, i
Accumulator variables: count, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int minCells ( int [ , ] mat , int m , int n ) { int [ , ] dp = new int [ m , n ] ; for ( int i = 0 ; i < m ; i ++ ) for ( int j = 0 ; j < n ; j ++ ) dp [ i , j ] = int . MaxValue ; dp [ 0 , 0 ] = 1 ; for ( int i = 0 ; i < m ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { if ( dp [ i , j ] != int . MaxValue && ( j + mat [ i , j ] ) < n && ( dp [ i , j ] + 1 ) < dp [ i , j + mat [ i , j ] ] ) dp [ i , j + mat [ i , j ] ] = dp [ i , j ] + 1 ; if ( dp [ i , j ] != int . MaxValue && ( i + mat [ i , j ] ) < m && ( dp [ i , j ] + 1 ) < dp [ i + mat [ i , j ] , j ] ) dp [ i + mat [ i , j ] , j ] = dp [ i , j ] + 1 ; } } if ( dp [ m - 1 , n - 1 ] != int . MaxValue ) return dp [ m - 1 , n - 1 ] ; return - 1 ; } public static void Main ( ) { int [ , ] mat = { { 2 , 3 , 2 , 1 , 4 } , { 3 , 2 , 5 , 8 , 2 } , { 1 , 1 , 2 , 2 , 1 } } ; int m = 3 , n = 5 ; Console . WriteLine ( " Minimum ▁ number ▁ of ▁ " + " cells ▁ = ▁ " + minCells ( mat , m , n ) ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static List < int > res = new List < int > ( ) ; static int GetCeilIndex ( int [ ] arr , int [ ] T , int l , int r , int key ) { while ( r - l > 1 ) { int m = l + ( r - l ) / 2 ; if ( arr [ T [ m ] ] >= key ) r = m ; else l = m ; } return r ; } static int [ ] reverse ( int [ ] a ) { int i , n = a . Length , t ; for ( i = 0 ; i < n / 2 ; i ++ ) { t = a [ i ] ; a [ i ] = a [ n - i - 1 ] ; a [ n - i - 1 ] = t ; } return a ; } static void LIS ( int [ ] arr , int n ) { int [ ] tailIndices = new int [ n ] ; int [ ] prevIndices = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { tailIndices [ i ] = 0 ; prevIndices [ i ] = - 1 ; } int len = 1 ; for ( int i = 1 ; i < n ; i ++ ) { if ( arr [ i ] < arr [ tailIndices [ 0 ] ] ) tailIndices [ 0 ] = i ; else if ( arr [ i ] > arr [ tailIndices [ len - 1 ] ] ) { prevIndices [ i ] = tailIndices [ len - 1 ] ; tailIndices [ len ++ ] = i ; } else { int pos = GetCeilIndex ( arr , tailIndices , - 1 , len - 1 , arr [ i ] ) ; prevIndices [ i ] = tailIndices [ pos - 1 ] ; tailIndices [ pos ] = i ; } } for ( int i = tailIndices [ len - 1 ] ; i >= 0 ; i = prevIndices [ i ] ) res . Add ( arr [ i ] ) ; } static void longestBitonic ( int [ ] arr1 , int n1 , int [ ] arr2 , int n2 ) { LIS ( arr1 , n1 ) ; res . Reverse ( ) ; arr2 = reverse ( arr2 ) ; LIS ( arr2 , n2 ) ; for ( int i = 0 ; i < res . Count ; i ++ ) Console . Write ( res [ i ] + " ▁ " ) ; } public static void Main ( String [ ] args ) { int [ ] arr1 = { 1 , 2 , 4 , 3 , 2 } ; int [ ] arr2 = { 8 , 6 , 4 , 7 , 8 , 9 } ; int n1 = arr1 . Length ; int n2 = arr2 . Length ; longestBitonic ( arr1 , n1 , arr2 , n2 ) ; } }

Index/key variables: i, m, n, pos
Accumulator variables: i, len
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static readonly int R = 3 ; static readonly int C = 3 ; static int cal ( int [ , ] ones , int x , int y , int k ) { return ones [ x + k - 1 , y + k - 1 ] - ones [ x - 1 , y + k - 1 ] - ones [ x + k - 1 , y - 1 ] + ones [ x - 1 , y - 1 ] ; } static int sol ( int [ , ] mat ) { int ans = 0 ; int val = 0 ; int [ , ] ones = new int [ R + 1 , C + 1 ] ; for ( int i = 1 ; i <= R ; i ++ ) for ( int j = 1 ; j <= C ; j ++ ) { if ( mat [ i - 1 , j - 1 ] == 1 ) val = 1 ; ones [ i , j ] = ones [ i - 1 , j ] + ones [ i , j - 1 ] - ones [ i - 1 , j - 1 ] + ( val ) ; } for ( int k = 1 ; k <= Math . Min ( R , C ) ; k ++ ) for ( int i = 1 ; i + k - 1 <= R ; i ++ ) for ( int j = 1 ; j + k - 1 <= C ; j ++ ) ans = Math . Max ( ans , ( ones [ R , C ] + k * k - 2 * cal ( ones , i , j , k ) ) ) ; return ans ; } static public void Main ( ) { int [ , ] mat = { { 0 , 0 , 1 } , { 0 , 0 , 1 } , { 1 , 0 , 1 } } ; Console . WriteLine ( sol ( mat ) ) ; } }

Accumulator variables: i, j, k
Iterator variables: i, j, k
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; public class GfG { public class Node { public int data ; public Node left ; public Node right ; } public static Node newNode ( int data ) { Node node = new Node ( ) ; node . data = data ; node . left = null ; node . right = null ; return ( node ) ; } public static int maxNodeLevel ( Node root ) { if ( root == null ) { return - 1 ; } LinkedList < Node > q = new LinkedList < Node > ( ) ; q . AddLast ( root ) ; int level = 0 ; int max = int . MinValue ; int level_no = 0 ; while ( true ) { int NodeCount = q . Count ; if ( NodeCount == 0 ) { break ; } if ( NodeCount > max ) { max = NodeCount ; level_no = level ; } while ( NodeCount > 0 ) { Node Node = q . First . Value ; q . RemoveFirst ( ) ; if ( Node . left != null ) { q . AddLast ( Node . left ) ; } if ( Node . right != null ) { q . AddLast ( Node . right ) ; } NodeCount -- ; } level ++ ; } return level_no ; } public static void Main ( string [ ] args ) { Node root = newNode ( 2 ) ; root . left = newNode ( 1 ) ; root . right = newNode ( 3 ) ; root . left . left = newNode ( 4 ) ; root . left . right = newNode ( 6 ) ; root . right . right = newNode ( 8 ) ; root . left . right . left = newNode ( 5 ) ; Console . WriteLine ( " Level ▁ having ▁ maximum ▁ number ▁ of ▁ Nodes ▁ : ▁ " + maxNodeLevel ( root ) ) ; } }

Accumulator variables: NodeCount, level
Class/struct names: GfG, Node
C# program:
using System ; class GFG { static int getMinSteps ( int n ) { int [ ] table = new int [ n + 1 ] ; for ( int i = 0 ; i <= n ; i ++ ) table [ i ] = n - i ; for ( int i = n ; i >= 1 ; i -- ) { if ( ! ( i % 2 > 0 ) ) table [ i / 2 ] = Math . Min ( table [ i ] + 1 , table [ i / 2 ] ) ; if ( ! ( i % 3 > 0 ) ) table [ i / 3 ] = Math . Min ( table [ i ] + 1 , table [ i / 3 ] ) ; } return table [ 1 ] ; } public static void Main ( ) { int n = 10 ; Console . WriteLine ( getMinSteps ( n ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static readonly int M = 3 ; static readonly int N = 3 ; static int findMaxPoints ( int [ , ] A ) { int [ , ] P1S = new int [ M + 2 , N + 2 ] ; int [ , ] P1E = new int [ M + 2 , N + 2 ] ; int [ , ] P2S = new int [ M + 2 , N + 2 ] ; int [ , ] P2E = new int [ M + 2 , N + 2 ] ; for ( int i = 1 ; i <= N ; i ++ ) for ( int j = 1 ; j <= M ; j ++ ) P1S [ i , j ] = Math . Max ( P1S [ i - 1 , j ] , P1S [ i , j - 1 ] ) + A [ i - 1 , j - 1 ] ; for ( int i = N ; i >= 1 ; i -- ) for ( int j = M ; j >= 1 ; j -- ) P1E [ i , j ] = Math . Max ( P1E [ i + 1 , j ] , P1E [ i , j + 1 ] ) + A [ i - 1 , j - 1 ] ; for ( int i = N ; i >= 1 ; i -- ) for ( int j = 1 ; j <= M ; j ++ ) P2S [ i , j ] = Math . Max ( P2S [ i + 1 , j ] , P2S [ i , j - 1 ] ) + A [ i - 1 , j - 1 ] ; for ( int i = 1 ; i <= N ; i ++ ) for ( int j = M ; j >= 1 ; j -- ) P2E [ i , j ] = Math . Max ( P2E [ i - 1 , j ] , P2E [ i , j + 1 ] ) + A [ i - 1 , j - 1 ] ; int ans = 0 ; for ( int i = 2 ; i < N ; i ++ ) { for ( int j = 2 ; j < M ; j ++ ) { int op1 = P1S [ i , j - 1 ] + P1E [ i , j + 1 ] + P2S [ i + 1 , j ] + P2E [ i - 1 , j ] ; int op2 = P1S [ i - 1 , j ] + P1E [ i + 1 , j ] + P2S [ i , j - 1 ] + P2E [ i , j + 1 ] ; ans = Math . Max ( ans , Math . Max ( op1 , op2 ) ) ; } } return ans ; } public static void Main ( String [ ] args ) { int [ , ] A = { { 100 , 100 , 100 } , { 100 , 1 , 100 } , { 100 , 100 , 100 } } ; Console . Write ( " Max ▁ Points ▁ : ▁ " + findMaxPoints ( A ) ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int longestSubseqWithDiffOne ( int [ ] arr , int n ) { int [ ] dp = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) dp [ i ] = 1 ; for ( int i = 1 ; i < n ; i ++ ) { for ( int j = 0 ; j < i ; j ++ ) { if ( ( arr [ i ] == arr [ j ] + 1 ) || ( arr [ i ] == arr [ j ] - 1 ) ) dp [ i ] = Math . Max ( dp [ i ] , dp [ j ] + 1 ) ; } } int result = 1 ; for ( int i = 0 ; i < n ; i ++ ) if ( result < dp [ i ] ) result = dp [ i ] ; return result ; } public static void Main ( ) { int [ ] arr = { 1 , 2 , 3 , 4 , 5 , 3 , 2 } ; int n = arr . Length ; Console . Write ( longestSubseqWithDiffOne ( arr , n ) ) ; } }

Index/key variables: i, j, n
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int catalanDP ( int n ) { int [ ] catalan = new int [ n + 1 ] ; catalan [ 0 ] = catalan [ 1 ] = 1 ; for ( int i = 2 ; i <= n ; i ++ ) { catalan [ i ] = 0 ; for ( int j = 0 ; j < i ; j ++ ) catalan [ i ] += catalan [ j ] * catalan [ i - j - 1 ] ; } return catalan [ n ] ; } static int countWays ( int n ) { if ( n < 1 ) { Console . WriteLine ( " Invalid " ) ; return 0 ; } return catalanDP ( n / 2 ) ; } static public void Main ( ) { Console . WriteLine ( countWays ( 6 ) + " ▁ " ) ; } }

Index/key variables: i, j, n
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class longestIncreasingSubsequence { public static void Main ( String [ ] args ) { int [ ] array = { 10 , 22 , 9 , 33 , 21 , 50 , 41 , 60 , 80 } ; List < int > list = new List < int > ( ) ; List < int > longestList = new List < int > ( ) ; int currentMax ; int highestCount = 0 ; for ( int i = 0 ; i < array . Length ; i ++ ) { currentMax = int . MinValue ; for ( int j = i ; j < array . Length ; j ++ ) { if ( array [ j ] > currentMax ) { list . Add ( array [ j ] ) ; currentMax = array [ j ] ; } } if ( highestCount < list . Count ) { highestCount = list . Count ; longestList = new List < int > ( list ) ; } list . Clear ( ) ; } Console . WriteLine ( ) ; Console . WriteLine ( " The ▁ longest ▁ subsequence " ) ; foreach ( int itr in longestList ) { Console . Write ( itr + " ▁ " ) ; } Console . WriteLine ( ) ; Console . WriteLine ( " Length ▁ of ▁ LIS : ▁ " + highestCount ) ; } }

Index/key variables: j
Accumulator variables: i, j
Iterator variables: i, itr, j
Class/struct names: longestIncreasingSubsequence
C# program:
using System ; class GFG { static int MAX = 101 ; static int [ , , , ] dp = new int [ MAX , MAX , MAX , 4 ] ; static int countWays ( int p , int q , int r , int last ) { if ( p < 0 q < 0 r < 0 ) return 0 ; if ( p == 1 && q == 0 && r == 0 && last == 0 ) return 1 ; if ( p == 0 && q == 1 && r == 0 && last == 1 ) return 1 ; if ( p == 0 && q == 0 && r == 1 && last == 2 ) return 1 ; if ( dp [ p , q , r , last ] != - 1 ) return dp [ p , q , r , last ] ; if ( last == 0 ) dp [ p , q , r , last ] = countWays ( p - 1 , q , r , 1 ) + countWays ( p - 1 , q , r , 2 ) ; else if ( last == 1 ) dp [ p , q , r , last ] = countWays ( p , q - 1 , r , 0 ) + countWays ( p , q - 1 , r , 2 ) ; else dp [ p , q , r , last ] = countWays ( p , q , r - 1 , 0 ) + countWays ( p , q , r - 1 , 1 ) ; return dp [ p , q , r , last ] ; } static int countUtil ( int p , int q , int r ) { for ( int i = 0 ; i < MAX ; i ++ ) for ( int j = 0 ; j < MAX ; j ++ ) for ( int k = 0 ; k < MAX ; k ++ ) for ( int l = 0 ; l < 4 ; l ++ ) dp [ i , j , k , l ] = - 1 ; } static void Main ( ) { int p = 1 , q = 1 , r = 1 ; Console . WriteLine ( countUtil ( p , q , r ) ) ; } }

Accumulator variables: i, j, k, l
Iterator variables: i, j, k, l
Class/struct names: GFG
C# program:
using System ; class GFG { static int countDer ( int n ) { if ( n == 1 ) return 0 ; if ( n == 2 ) return 1 ; return ( n - 1 ) * ( countDer ( n - 1 ) + countDer ( n - 2 ) ) ; } public static void Main ( ) { int n = 4 ; Console . Write ( " Count ▁ of ▁ Derangements ▁ is ▁ " + countDer ( n ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int countDer ( int n ) { int [ ] der = new int [ n + 1 ] ; der [ 1 ] = 0 ; der [ 2 ] = 1 ; for ( int i = 3 ; i <= n ; ++ i ) der [ i ] = ( i - 1 ) * ( der [ i - 1 ] + der [ i - 2 ] ) ; return der [ n ] ; } public static void Main ( ) { int n = 4 ; Console . Write ( " Count ▁ of ▁ Derangements ▁ is ▁ " + countDer ( n ) ) ; } }

Index/key variables: i, n
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int countSol ( int [ ] coeff , int n , int rhs ) { int [ ] dp = new int [ rhs + 1 ] ; dp [ 0 ] = 1 ; for ( int i = 0 ; i < n ; i ++ ) for ( int j = coeff [ i ] ; j <= rhs ; j ++ ) dp [ j ] += dp [ j - coeff [ i ] ] ; return dp [ rhs ] ; } public static void Main ( ) { int [ ] coeff = { 2 , 2 , 5 } ; int rhs = 4 ; int n = coeff . Length ; Console . Write ( countSol ( coeff , n , rhs ) ) ; } }

Index/key variables: i, j, rhs
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { public static void palindromeSubStrs ( string s ) { Dictionary < string , int > m = new Dictionary < string , int > ( ) ; int n = s . Length ; int [ , ] R = new int [ 2 , n + 1 ] ; s = " @ " + s + " # " ; for ( int j = 0 ; j <= 1 ; j ++ ) { R [ j , 0 ] = 0 ; int i = 1 ; while ( i <= n ) { while ( s [ i - rp - 1 ] == s [ i + j + rp ] ) rp ++ ; R [ j , i ] = rp ; int k = 1 ; while ( ( R [ j , i - k ] != rp - k ) && k < rp ) { R [ j , i + k ] = Math . Min ( R [ j , i - k ] , rp - k ) ; k ++ ; } rp = Math . Max ( rp - k , 0 ) ; i += k ; } } s = s . Substring ( 1 ) ; if ( ! m . ContainsKey ( s . Substring ( 0 , 1 ) ) ) m . Add ( s . Substring ( 0 , 1 ) , 1 ) ; else m [ s . Substring ( 0 , 1 ) ] ++ ; for ( int i = 1 ; i < n ; i ++ ) { for ( int j = 0 ; j <= 1 ; j ++ ) for ( int rp = R [ j , i ] ; rp > 0 ; rp -- ) { if ( ! m . ContainsKey ( s . Substring ( i - rp - 1 , 2 * rp + j ) ) ) m . Add ( s . Substring ( i - rp - 1 , 2 * rp + j ) , 1 ) ; else m [ s . Substring ( i - rp - 1 , 2 * rp + j ) ] ++ ; } if ( ! m . ContainsKey ( s . Substring ( i , 1 ) ) ) m . Add ( s . Substring ( i , 1 ) , 1 ) ; else m [ s . Substring ( i , 1 ) ] ++ ; } Console . WriteLine ( " Below ▁ are ▁ " + ( m . Count ) ) ; foreach ( KeyValuePair < string , int > ii in m ) Console . WriteLine ( ii . Key ) ; } public static void Main ( string [ ] args ) { palindromeSubStrs ( " abaaa " ) ; } }

Accumulator variables: i, j, k, rp
Iterator variables: i, ii, j, rp
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GfG { class Node { public int data ; public Node left = null ; public Node right = null ; } static Node newNode ( int val ) { Node temp = new Node ( ) ; temp . data = val ; temp . left = null ; temp . right = null ; return temp ; } static void largestValueInEachLevel ( Node root ) { if ( root == null ) return ; Queue < Node > q = new Queue < Node > ( ) ; int nc , max ; q . Enqueue ( root ) ; while ( true ) { nc = q . Count ; if ( nc == 0 ) break ; max = int . MinValue ; while ( nc != 0 ) { Node front = q . Peek ( ) ; q . Dequeue ( ) ; if ( max < front . data ) max = front . data ; if ( front . left != null ) q . Enqueue ( front . left ) ; if ( front . right != null ) q . Enqueue ( front . right ) ; nc -- ; } Console . Write ( max + " ▁ " ) ; } } public static void Main ( String [ ] args ) { Node root = null ; root = newNode ( 4 ) ; root . left = newNode ( 9 ) ; root . right = newNode ( 2 ) ; root . left . left = newNode ( 3 ) ; root . left . right = newNode ( 5 ) ; root . right . right = newNode ( 7 ) ; largestValueInEachLevel ( root ) ; } }

Accumulator variables: nc
Class/struct names: GfG, Node
C# program:
using System ; class BinaryTree { class Node { public int data ; public Node left , right , next ; public Node ( int item ) { data = item ; left = right = next = null ; } } Node root ; static Node next = null ; void populateNext ( Node node ) { if ( node != null ) { populateNext ( node . right ) ; node . next = next ; next = node ; populateNext ( node . left ) ; } } static public void Main ( String [ ] args ) { BinaryTree tree = new BinaryTree ( ) ; tree . root = new Node ( 10 ) ; tree . root . left = new Node ( 8 ) ; tree . root . right = new Node ( 12 ) ; tree . root . left . left = new Node ( 3 ) ; tree . populateNext ( tree . root ) ; Node ptr = tree . root . left . left ; while ( ptr != null ) { int print = ptr . next != null ? ptr . next . data : - 1 ; Console . WriteLine ( " Next ▁ of ▁ " + ptr . data + " ▁ is : ▁ " + print ) ; ptr = ptr . next ; } } }

Class/struct names: BinaryTree, Node
C# program:
using System ; class GFG { static int findWays ( int m , int n , int x ) { int [ , ] table = new int [ n + 1 , x + 1 ] ; for ( int i = 0 ; i <= n ; i ++ ) for ( int j = 0 ; j <= x ; j ++ ) table [ i , j ] = 0 ; for ( int j = 1 ; j <= m && j <= x ; j ++ ) table [ 1 , j ] = 1 ; for ( int i = 2 ; i <= n ; i ++ ) for ( int j = 1 ; j <= x ; j ++ ) for ( int k = 1 ; k <= m && k < j ; k ++ ) table [ i , j ] += table [ i - 1 , j - k ] ; return table [ n , x ] ; } public static void Main ( ) { Console . WriteLine ( findWays ( 4 , 2 , 1 ) ) ; Console . WriteLine ( findWays ( 2 , 2 , 3 ) ) ; Console . WriteLine ( findWays ( 6 , 3 , 8 ) ) ; Console . WriteLine ( findWays ( 4 , 2 , 5 ) ) ; Console . WriteLine ( findWays ( 4 , 3 , 5 ) ) ; } }

Accumulator variables: i, j, k
Iterator variables: i, j, k
Class/struct names: GFG
C# program:
using System ; class GFG { public static long findWays ( int f , int d , int s ) { long [ , ] mem = new long [ d + 1 , s + 1 ] ; mem [ 0 , 0 ] = 1 ; for ( int i = 1 ; i <= d ; i ++ ) { for ( int j = i ; j <= s ; j ++ ) { mem [ i , j ] = mem [ i , j - 1 ] + mem [ i - 1 , j - 1 ] ; if ( j - f - 1 >= 0 ) mem [ i , j ] -= mem [ i - 1 , j - f - 1 ] ; } } return mem [ d , s ] ; } public static void Main ( String [ ] args ) { Console . WriteLine ( findWays ( 4 , 2 , 1 ) ) ; Console . WriteLine ( findWays ( 2 , 2 , 3 ) ) ; Console . WriteLine ( findWays ( 6 , 3 , 8 ) ) ; Console . WriteLine ( findWays ( 4 , 2 , 5 ) ) ; Console . WriteLine ( findWays ( 4 , 3 , 5 ) ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int findMinInsertions ( char [ ] str , int l , int h ) { if ( l > h ) return int . MaxValue ; if ( l == h ) return 0 ; if ( l == h - 1 ) return ( str [ l ] == str [ h ] ) ? 0 : 1 ; return ( str [ l ] == str [ h ] ) ? findMinInsertions ( str , l + 1 , h - 1 ) : ( Math . Min ( findMinInsertions ( str , l , h - 1 ) , findMinInsertions ( str , l + 1 , h ) ) + 1 ) ; } public static void Main ( ) { string str = " geeks " ; Console . WriteLine ( findMinInsertions ( str . ToCharArray ( ) , 0 , str . Length - 1 ) ) ; } }

Index/key variables: h, l
Class/struct names: GFG
C# program:
using System ; public class GFG { static int max ( int x , int y ) { return ( x > y ) ? x : y ; } static int lps ( char [ ] seq , int i , int j ) { if ( i == j ) { return 1 ; } if ( seq [ i ] == seq [ j ] && i + 1 == j ) { return 2 ; } if ( seq [ i ] == seq [ j ] ) { return lps ( seq , i + 1 , j - 1 ) + 2 ; } return max ( lps ( seq , i , j - 1 ) , lps ( seq , i + 1 , j ) ) ; } public static void Main ( ) { String seq = " GEEKSFORGEEKS " ; int n = seq . Length ; Console . Write ( " The ▁ length ▁ of ▁ the ▁ LPS ▁ is ▁ " + lps ( seq . ToCharArray ( ) , 0 , n - 1 ) ) ; } }

Index/key variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int INT_MAX = ( int ) 10e6 ; public class Node { public int data ; public Node left , right ; } ; static int heightoftree ( Node root ) { if ( root == null ) return 0 ; int left = heightoftree ( root . left ) ; int right = heightoftree ( root . right ) ; return ( ( left > right ? left : right ) + 1 ) ; } static void printPerLevelMinimum ( Node root , int [ ] res , int level ) { if ( root != null ) { printPerLevelMinimum ( root . left , res , level + 1 ) ; if ( root . data < res [ level ] ) res [ level ] = root . data ; printPerLevelMinimum ( root . right , res , level + 1 ) ; } } static void perLevelMinimumUtility ( Node root ) { int n = heightoftree ( root ) , i ; int [ ] res = new int [ n ] ; for ( i = 0 ; i < n ; i ++ ) res [ i ] = INT_MAX ; printPerLevelMinimum ( root , res , 0 ) ; Console . Write ( " Every ▁ level ▁ minimum ▁ is STRNEWLINE " ) ; for ( i = 0 ; i < n ; i ++ ) { Console . Write ( " level ▁ " + i + " ▁ min ▁ is ▁ = ▁ " + res [ i ] + " STRNEWLINE " ) ; } } static Node newNode ( int data ) { Node temp = new Node ( ) ; temp . data = data ; temp . left = temp . right = null ; return temp ; } public static void Main ( String [ ] args ) { Node root = newNode ( 7 ) ; root . left = newNode ( 6 ) ; root . right = newNode ( 5 ) ; root . left . left = newNode ( 4 ) ; root . left . right = newNode ( 3 ) ; root . right . left = newNode ( 2 ) ; root . right . right = newNode ( 1 ) ; perLevelMinimumUtility ( root ) ; } }

Index/key variables: i, level, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG, Node
C# program:
using System ; using System . Collections . Generic ; class GFG { class Node { public int data ; public Node left , right ; } ; static int heightoftree ( Node root ) { if ( root == null ) return 0 ; int left = heightoftree ( root . left ) ; int right = heightoftree ( root . right ) ; return ( ( left > right ? left : right ) + 1 ) ; } static void printPerLevelMinimum ( Node root ) { if ( root == null ) return ; Queue < Node > q = new Queue < Node > ( ) ; q . Enqueue ( root ) ; q . Enqueue ( null ) ; int min = int . MaxValue ; int level = 0 ; while ( q . Count != 0 ) { Node node = q . Peek ( ) ; q . Dequeue ( ) ; if ( node == null ) { Console . Write ( " level ▁ " + level + " ▁ min ▁ is ▁ = ▁ " + min + " STRNEWLINE " ) ; if ( q . Count == 0 ) break ; q . Enqueue ( null ) ; level ++ ; min = int . MaxValue ; continue ; } if ( min > node . data ) min = node . data ; if ( node . left != null ) { q . Enqueue ( node . left ) ; } if ( node . right != null ) { q . Enqueue ( node . right ) ; } } } static Node newNode ( int data ) { Node temp = new Node ( ) ; temp . data = data ; temp . left = temp . right = null ; return temp ; } public static void Main ( String [ ] args ) { Node root = newNode ( 7 ) ; root . left = newNode ( 6 ) ; root . right = newNode ( 5 ) ; root . left . left = newNode ( 4 ) ; root . left . right = newNode ( 3 ) ; root . right . left = newNode ( 2 ) ; root . right . right = newNode ( 1 ) ; Console . Write ( " Every ▁ Level ▁ minimum ▁ is " + " STRNEWLINE " ) ; printPerLevelMinimum ( root ) ; } }

Accumulator variables: level
Class/struct names: GFG, Node
C# program:
using System ; class GFG { static int findCount ( string str1 , string str2 ) { int len = str1 . Length ; int len2 = str2 . Length ; int ans = Int32 . MaxValue ; int [ ] hash1 = new int [ 26 ] ; int [ ] hash2 = new int [ 26 ] ; for ( int i = 0 ; i < len ; i ++ ) hash1 [ str1 [ i ] - ' a ' ] ++ ; for ( int i = 0 ; i < len2 ; i ++ ) hash2 [ str2 [ i ] - ' a ' ] ++ ; for ( int i = 0 ; i < 26 ; i ++ ) if ( hash2 [ i ] != 0 ) ans = Math . Min ( ans , hash1 [ i ] / hash2 [ i ] ) ; return ans ; } public static void Main ( ) { string str1 = " geeksclassesatnoida " ; string str2 = " sea " ; Console . WriteLine ( findCount ( str1 , str2 ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG