dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; using System . Collections . Generic ; class GFG { static int longIncrConseqSubseq ( int [ ] arr , int n ) { Dictionary < int , int > map = new Dictionary < int , int > ( ) ; map . Add ( arr [ 0 ] , 1 ) ; for ( int i = 1 ; i < n ; i ++ ) { if ( map . ContainsKey ( arr [ i ] - 1 ) ) { map . Add ( arr [ i ] , map [ arr [ i ] - 1 ] + 1 ) ; map . Remove ( arr [ i ] - 1 ) ; } else { if ( ! map . ContainsKey ( arr [ i ] ) ) map . Add ( arr [ i ] , 1 ) ; } } int max = int . MinValue ; foreach ( KeyValuePair < int , int > entry in map ) { if ( entry . Value > max ) { max = entry . Value ; } } return max ; } public static void Main ( String [ ] args ) { int [ ] arr = { 3 , 10 , 3 , 11 , 4 , 5 , 6 , 7 , 8 , 12 } ; int n = arr . Length ; Console . WriteLine ( longIncrConseqSubseq ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: entry, i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int longLenSub ( int [ ] arr , int n ) { Dictionary < int , int > um = new Dictionary < int , int > ( ) ; int longLen = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int len = 0 ; if ( um . ContainsKey ( arr [ i ] - 1 ) && len < um [ arr [ i ] - 1 ] ) len = um [ arr [ i ] - 1 ] ; if ( um . ContainsKey ( arr [ i ] + 1 ) && len < um [ arr [ i ] + 1 ] ) len = um [ arr [ i ] + 1 ] ; um [ arr [ i ] ] = len + 1 ; if ( longLen < um [ arr [ i ] ] ) longLen = um [ arr [ i ] ] ; } return longLen ; } static void Main ( ) { int [ ] arr = { 1 , 2 , 3 , 4 , 5 , 3 , 2 } ; int n = arr . Length ; Console . Write ( " Longest ▁ length ▁ subsequence ▁ = ▁ " + longLenSub ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GfG { static int count = 0 ; public class Node { public int val ; public Node left , right ; } static void find ( Node root , int max ) { if ( root == null ) return ; if ( root . val >= max ) count ++ ; find ( root . left , Math . Max ( max , root . val ) ) ; find ( root . right , Math . Max ( max , root . val ) ) ; } static int NodesMaxInPath ( Node root ) { find ( root , int . MinValue ) ; return count ; } static Node newNode ( int data ) { Node temp = new Node ( ) ; temp . val = data ; temp . left = null ; temp . right = null ; return temp ; } public static void Main ( String [ ] args ) { Node root = null ; root = newNode ( 3 ) ; root . left = newNode ( 2 ) ; root . right = newNode ( 5 ) ; root . left . left = newNode ( 4 ) ; root . right . right = newNode ( 7 ) ; int answer = NodesMaxInPath ( root ) ; Console . WriteLine ( answer ) ; } }

Accumulator variables: count
Class/struct names: GfG, Node
C# program:
using System ; using System . Collections . Generic ; class GFG { static int findLongestConseqSubseq ( int [ ] arr , int n ) { Array . Sort ( arr ) ; int ans = 0 , count = 0 ; List < int > v = new List < int > ( ) ; v . Add ( 10 ) ; for ( int i = 1 ; i < n ; i ++ ) { if ( arr [ i ] != arr [ i - 1 ] ) v . Add ( arr [ i ] ) ; } for ( int i = 0 ; i < v . Count ; i ++ ) { if ( i > 0 && v [ i ] == v [ i - 1 ] + 1 ) count ++ ; else count = 1 ; ans = Math . Max ( ans , count ) ; } return ans ; } static void Main ( ) { int [ ] arr = { 1 , 9 , 3 , 10 , 4 , 20 , 2 } ; int n = arr . Length ; Console . WriteLine ( " Length ▁ of ▁ the ▁ Longest ▁ " + " contiguous ▁ subsequence ▁ is ▁ " + findLongestConseqSubseq ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int maxn = ( int ) 1e6 + 5 ; static int [ ] BITree = new int [ maxn ] ; static bool is_prime ( int n ) { if ( n <= 1 ) return false ; for ( int i = 2 ; i * i <= n ; i ++ ) if ( n % i == 0 ) return false ; return true ; } static void update_bitree ( int [ ] BITree , int index , int value ) { while ( index <= maxn ) { BITree [ index ] += value ; index += ( index & ( - index ) ) ; } } static int sum_bitree ( int [ ] BITree , int index ) { int s = 0 ; while ( index > 0 ) { s += BITree [ index ] ; index -= ( index & ( - index ) ) ; } return s ; } static void countSmallerPrimes ( int [ ] BITree , int [ ] ar , int N ) { int [ ] ans = new int [ N ] ; for ( int i = N - 1 ; i >= 0 ; i -- ) { ans [ i ] = sum_bitree ( BITree , ar [ i ] ) ; if ( is_prime ( ar [ i ] ) ) update_bitree ( BITree , ar [ i ] , 1 ) ; } for ( int i = 0 ; i < N ; i ++ ) Console . Write ( ans [ i ] + " ▁ " ) ; } public static void Main ( String [ ] args ) { int [ ] ar = { 5 , 5 , 17 , 9 , 12 , 15 , 11 , 7 , 39 , 3 } ; int N = ar . Length ; countSmallerPrimes ( BITree , ar , N ) ; } }

Index/key variables: N, i, index, maxn
Accumulator variables: i, index, s
Iterator variables: i
Class/struct names: GFG
C# program:
public class ArrayElements { public static int findLongestConseqSubseq ( int [ ] arr , int n ) { HashSet < int > S = new HashSet < int > ( ) ; int ans = 0 ; for ( int i = 0 ; i < n ; ++ i ) { S . Add ( arr [ i ] ) ; } for ( int i = 0 ; i < n ; ++ i ) { if ( ! S . Contains ( arr [ i ] - 1 ) ) { int j = arr [ i ] ; while ( S . Contains ( j ) ) { j ++ ; } if ( ans < j - arr [ i ] ) { ans = j - arr [ i ] ; } } } return ans ; } public static void Main ( string [ ] args ) { int [ ] arr = new int [ ] { 1 , 9 , 3 , 10 , 4 , 20 , 2 } ; int n = arr . Length ; Console . WriteLine ( " Length ▁ of ▁ the ▁ Longest ▁ consecutive ▁ subsequence ▁ is ▁ " + findLongestConseqSubseq ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: j
Iterator variables: i
Class/struct names: ArrayElements
C# program:
using System ; class GFG { static void print_kth_String ( String str , int K ) { String [ ] iss = str . Split ( ' ▁ ' ) ; K -- ; Console . Write ( iss [ K ] ) ; } public static void Main ( String [ ] args ) { String s = ( "10 ▁ 20 ▁ 30 ▁ 40" ) ; int K = 2 ; print_kth_String ( s , K ) ; } }

Index/key variables: K
Accumulator variables: K
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void findLIS ( int [ ] A , int n ) { Dictionary < int , int > hash = new Dictionary < int , int > ( ) ; int LIS_size = 1 ; int LIS_index = 0 ; hash . Add ( A [ 0 ] , 1 ) ; for ( int i = 1 ; i < n ; i ++ ) { if ( hash . ContainsKey ( A [ i ] - 1 ) ) { var val = hash [ A [ i ] - 1 ] ; hash . Remove ( A [ i ] ) ; hash . Add ( A [ i ] , val + 1 ) ; } else { hash . Add ( A [ i ] , 1 ) ; } if ( LIS_size < hash [ A [ i ] ] ) { LIS_size = hash [ A [ i ] ] ; LIS_index = A [ i ] ; } } Console . WriteLine ( " LIS _ size ▁ = ▁ " + LIS_size ) ; Console . Write ( " LIS ▁ : ▁ " ) ; int start = LIS_index - LIS_size + 1 ; while ( start <= LIS_index ) { Console . Write ( start + " ▁ " ) ; start ++ ; } } public static void Main ( String [ ] args ) { int [ ] A = { 2 , 5 , 3 , 7 , 4 , 8 , 5 , 13 , 6 } ; int n = A . Length ; findLIS ( A , n ) ; } }

Index/key variables: i
Accumulator variables: i, start
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int countSubsets ( int [ ] arr , int n ) { HashSet < int > us = new HashSet < int > ( ) ; int even_count = 0 ; for ( int i = 0 ; i < n ; i ++ ) if ( arr [ i ] % 2 == 0 ) us . Add ( arr [ i ] ) ; even_count = us . Count ; return ( int ) ( Math . Pow ( 2 , even_count ) - 1 ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 4 , 2 , 1 , 9 , 2 , 6 , 5 , 3 } ; int n = arr . Length ; Console . WriteLine ( " Number ▁ of ▁ subsets ▁ = ▁ " + countSubsets ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int countWindowDistinct ( int [ ] win , int k ) { int dist_count = 0 ; for ( int i = 0 ; i < k ; i ++ ) { int j ; for ( j = 0 ; j < i ; j ++ ) if ( win [ i ] == win [ j ] ) break ; if ( j == i ) dist_count ++ ; } return dist_count ; } static void countDistinct ( int [ ] arr , int n , int k ) { for ( int i = 0 ; i <= n - k ; i ++ ) { int [ ] newArr = new int [ k ] ; Array . Copy ( arr , i , newArr , 0 , k ) ; Console . WriteLine ( countWindowDistinct ( newArr , k ) ) ; } } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 1 , 3 , 4 , 2 , 3 } ; int k = 4 ; countDistinct ( arr , arr . Length , k ) ; } }

Index/key variables: i, j, k
Accumulator variables: dist_count, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GfG { public class Node { public int data ; public Node left , right ; } static Node newNode ( int data ) { Node temp = new Node ( ) ; temp . data = data ; temp . left = null ; temp . right = null ; return temp ; } static String areMirrors ( Node root1 , Node root2 ) { Stack < Node > st1 = new Stack < Node > ( ) ; Stack < Node > st2 = new Stack < Node > ( ) ; while ( true ) { while ( root1 != null && root2 != null ) { if ( root1 . data != root2 . data ) return " No " ; st1 . Push ( root1 ) ; st2 . Push ( root2 ) ; root1 = root1 . left ; root2 = root2 . right ; } if ( ! ( root1 == null && root2 == null ) ) return " No " ; if ( st1 . Count != 0 && st2 . Count != 0 ) { root1 = st1 . Peek ( ) ; root2 = st2 . Peek ( ) ; st1 . Pop ( ) ; st2 . Pop ( ) ; root1 = root1 . right ; root2 = root2 . left ; } else break ; } return " Yes " ; } public static void Main ( String [ ] args ) { Node root1 = newNode ( 1 ) ; root1 . left = newNode ( 3 ) ; root1 . right = newNode ( 2 ) ; root1 . right . left = newNode ( 5 ) ; root1 . right . right = newNode ( 4 ) ; Node root2 = newNode ( 1 ) ; root2 . left = newNode ( 2 ) ; root2 . right = newNode ( 3 ) ; root2 . left . left = newNode ( 4 ) ; root2 . left . right = newNode ( 5 ) ; Console . WriteLine ( areMirrors ( root1 , root2 ) ) ; } }

Class/struct names: GfG, Node
C# program:
using System ; class GFG { public static int maximumSum ( int [ ] a , int [ ] b , int n , int index , int lastpicked , int [ , ] dp ) { if ( index == n ) return 0 ; if ( dp [ index , lastpicked + 1 ] != - 1 ) return dp [ index , lastpicked + 1 ] ; int option1 = 0 , option2 = 0 ; if ( lastpicked == - 1 a [ lastpicked ] != a [ index ] ) { option1 = b [ index ] + maximumSum ( a , b , n , index + 1 , index , dp ) ; } option2 = maximumSum ( a , b , n , index + 1 , lastpicked , dp ) ; return dp [ index , lastpicked + 1 ] = Math . Max ( option1 , option2 ) ; } public static void maximumPoints ( int [ ] arr , int [ ] brr , int n ) { int index = 0 , lastPicked = - 1 ; int [ , ] dp = new int [ n + 5 , n + 5 ] ; for ( int i = 0 ; i < n + 5 ; i ++ ) { for ( int j = 0 ; j < n + 5 ; j ++ ) { dp [ i , j ] = - 1 ; } } Console . WriteLine ( maximumSum ( arr , brr , n , index , lastPicked , dp ) ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 3 , 3 , 3 , 1 } ; int [ ] brr = { - 1 , 2 , 10 , 20 , - 10 , - 9 } ; int N = arr . Length ; maximumPoints ( arr , brr , N ) ; } }

Index/key variables: index, lastpicked
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; public class MaxPossibleSuminWindow { static int returnMaxSum ( int [ ] A , int [ ] B , int n ) { HashSet < int > mp = new HashSet < int > ( ) ; int result = 0 ; int curr_sum = 0 , curr_begin = 0 ; for ( int i = 0 ; i < n ; ++ i ) { while ( mp . Contains ( A [ i ] ) ) { mp . Remove ( A [ curr_begin ] ) ; curr_sum -= B [ curr_begin ] ; curr_begin ++ ; } mp . Add ( A [ i ] ) ; curr_sum += B [ i ] ; result = Math . Max ( result , curr_sum ) ; } return result ; } public static void Main ( String [ ] args ) { int [ ] A = { 0 , 1 , 2 , 3 , 0 , 1 , 4 } ; int [ ] B = { 9 , 8 , 1 , 2 , 3 , 4 , 5 } ; int n = A . Length ; Console . WriteLine ( returnMaxSum ( A , B , n ) ) ; } }

Index/key variables: curr_begin, i
Accumulator variables: curr_begin, curr_sum
Iterator variables: i
Class/struct names: MaxPossibleSuminWindow
C# program:
using System . Collections . Generic ; using System ; class GFG { static void FindMax ( int [ ] arr , int N ) { int maxi = - 1 ; int maxi2 = - 1 ; int count = 0 ; for ( int i = 0 ; i < N ; ++ i ) { if ( arr [ i ] == 0 ) count = 0 ; else { count ++ ; maxi = Math . Max ( maxi , count ) ; } } for ( int i = 0 ; i < N ; i ++ ) { if ( arr [ i ] == 1 ) { count ++ ; if ( count > maxi2 && count < maxi ) { maxi2 = count ; } } if ( arr [ i ] == 0 ) count = 0 ; } maxi = Math . Max ( maxi , 0 ) ; maxi2 = Math . Max ( maxi2 , 0 ) ; Console . WriteLine ( maxi2 ) ; } public static void Main ( ) { int [ ] arr = { 1 , 1 , 1 , 0 , 0 , 1 , 1 } ; int n = arr . Length ; FindMax ( arr , n ) ; } }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static Dictionary < int , Boolean > mp = new Dictionary < int , Boolean > ( ) ; class Node { public int key ; public Node left , right ; } ; static Node newNode ( int key ) { Node temp = new Node ( ) ; temp . key = key ; temp . left = temp . right = null ; return ( temp ) ; } static void calculateMin ( Node root , List < int > levelMin ) { Queue < Node > qt = new Queue < Node > ( ) ; qt . Enqueue ( root ) ; int count = 1 ; int min_v = int . MaxValue ; while ( qt . Count != 0 ) { Node temp = qt . Peek ( ) ; min_v = Math . Min ( min_v , temp . key ) ; qt . Dequeue ( ) ; if ( temp . left != null ) { qt . Enqueue ( temp . left ) ; } if ( temp . right != null ) { qt . Enqueue ( temp . right ) ; } count -- ; if ( count == 0 ) { levelMin . Add ( min_v ) ; min_v = int . MaxValue ; count = qt . Count ; } } } static void findNodes ( Node root , List < int > levelMin , int [ ] levelResult , int level ) { if ( root == null ) return ; findNodes ( root . left , levelMin , levelResult , level + 1 ) ; findNodes ( root . right , levelMin , levelResult , level + 1 ) ; for ( int i = 0 ; i < level ; i ++ ) { if ( root . key <= levelMin [ i ] ) { levelResult [ i ] += 1 ; } } } static void printNodes ( Node root ) { List < int > levelMin = new List < int > ( ) ; calculateMin ( root , levelMin ) ; int numLevels = levelMin . Count ; int [ ] levelResult = new int [ numLevels ] ; findNodes ( root , levelMin , levelResult , 0 ) ; for ( int i = 0 ; i < numLevels ; i ++ ) { Console . Write ( levelResult [ i ] + " ▁ " ) ; } } public static void Main ( String [ ] args ) { Node root = newNode ( 4 ) ; root . left = newNode ( 3 ) ; root . right = newNode ( 5 ) ; root . right . left = newNode ( 3 ) ; root . right . right = newNode ( 1 ) ; root . left . left = newNode ( 10 ) ; root . left . right = newNode ( 2 ) ; printNodes ( root ) ; } }

Index/key variables: i, numLevels
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG, Node
C# program:
using System ; class GFG { static int countSubArray ( int [ ] arr , int n ) { if ( n < 2 ) return n ; int i = max_element ( arr ) ; int j = min_element ( arr ) ; if ( i > j ) { int tmp = arr [ i ] ; arr [ i ] = arr [ j ] ; arr [ j ] = tmp ; } return ( i + 1 ) * ( n - j ) ; } static int max_element ( int [ ] arr ) { int idx = 0 ; int max = arr [ 0 ] ; for ( int i = 1 ; i < arr . Length ; i ++ ) { if ( max < arr [ i ] ) { max = arr [ i ] ; idx = i ; } } return idx ; } static int min_element ( int [ ] arr ) { int idx = 0 ; int min = arr [ 0 ] ; for ( int i = 1 ; i < arr . Length ; i ++ ) { if ( arr [ i ] < min ) { min = arr [ i ] ; idx = i ; } } return idx ; } public static void Main ( String [ ] args ) { int [ ] arr = { 4 , 1 , 2 , 3 } ; int n = arr . Length ; Console . WriteLine ( countSubArray ( arr , n ) ) ; } }

Index/key variables: i, j
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class Node { public int data ; public Node left , right ; public Node ( int item ) { data = item ; left = right = null ; } } class GFG { Node root ; static int result ; static int [ ] dfs ( Node root , int distance ) { int [ ] res ; if ( root == null ) return new int [ distance + 1 ] ; if ( root . left == null && root . right == null ) { res = new int [ distance + 1 ] ; res [ 1 ] ++ ; return res ; } int [ ] left = dfs ( root . left , distance ) ; int [ ] right = dfs ( root . right , distance ) ; res = new int [ distance + 1 ] ; for ( int i = res . Length - 2 ; i >= 1 ; i -- ) { res [ i + 1 ] = left [ i ] + right [ i ] ; } for ( int l = 1 ; l < left . Length ; l ++ ) { for ( int r = 0 ; r < right . Length ; r ++ ) { if ( l + r <= distance ) { result += left [ l ] * right [ r ] ; } } } return res ; } public static void Main ( String [ ] args ) { GFG tree = new GFG ( ) ; tree . root = new Node ( 1 ) ; tree . root . left = new Node ( 2 ) ; tree . root . right = new Node ( 3 ) ; tree . root . left . left = new Node ( 4 ) ; result = 0 ; int K = 3 ; dfs ( tree . root , K ) ; Console . WriteLine ( result ) ; } }

Index/key variables: i, l, r
Accumulator variables: i, l, r, result
Iterator variables: i, l, r
Class/struct names: GFG, Node
C# program:
using System ; using System . Collections . Generic ; class GFG { static void maxAbsDiffLevelSum ( int N , int M , int [ ] cost , int [ , ] Edges ) { List < int > [ ] adj = new List < int > [ N ] ; for ( int i = 0 ; i < adj . Length ; i ++ ) adj [ i ] = new List < int > ( ) ; for ( int i = 0 ; i < M ; i ++ ) { int u = Edges [ i , 0 ] ; int v = Edges [ i , 1 ] ; adj [ u ] . Add ( v ) ; } int maxSum = cost [ 0 ] , minSum = cost [ 0 ] ; Queue < int > q = new Queue < int > ( ) ; q . Enqueue ( 0 ) ; while ( q . Count != 0 ) { int count = q . Count ; int sum = 0 ; while ( count -- > 0 ) { int temp = q . Peek ( ) ; q . Dequeue ( ) ; sum = sum + cost [ temp ] ; for ( int i = 0 ; i < adj [ temp ] . Count ; i ++ ) { q . Enqueue ( adj [ temp ] [ i ] ) ; } } maxSum = Math . Max ( sum , maxSum ) ; minSum = Math . Min ( sum , minSum ) ; } Console . Write ( Math . Abs ( maxSum - minSum ) ) ; } public static void Main ( String [ ] args ) { int N = 10 , M = 9 ; int [ , ] Edges = { { 0 , 1 } , { 0 , 2 } , { 0 , 3 } , { 1 , 4 } , { 1 , 5 } , { 3 , 6 } , { 6 , 7 } , { 6 , 8 } , { 6 , 9 } } ; int [ ] cost = { 1 , 2 , - 1 , 3 , 4 , 5 , 8 , 6 , 12 , 7 } ; maxAbsDiffLevelSum ( N , M , cost , Edges ) ; } }

Index/key variables: N, i, temp, u
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Linq ; class GFG { static long findMinCost ( int [ ] a , int k , int n ) { int max_ele = a . Max ( ) ; long [ ] dp = new long [ n + 1 ] ; for ( int i = 1 ; i <= n ; ++ i ) dp [ i ] = int . MaxValue ; dp [ 0 ] = 0 ; for ( int i = 0 ; i < n ; ++ i ) { int [ ] freq = new int [ max_ele + 1 ] ; for ( int j = i ; j < n ; ++ j ) { freq [ a [ j ] ] ++ ; int cost = 0 ; for ( int x = 0 ; x <= max_ele ; ++ x ) { cost += ( freq [ x ] == 1 ) ? 0 : freq [ x ] ; } dp [ j + 1 ] = Math . Min ( dp [ i ] + cost + k , dp [ j + 1 ] ) ; } } return dp [ n ] ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 1 , 1 , 1 } ; int K = 2 ; int n = arr . Length ; Console . Write ( findMinCost ( arr , K , n ) ) ; } }

Index/key variables: i, j, n, x
Accumulator variables: cost
Iterator variables: i, j, x
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; public class GFG { public static void subArraySum ( int [ ] arr , int n , int sum ) { int cur_sum = 0 ; int start = 0 ; int end = - 1 ; Dictionary < int , int > hashMap = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { cur_sum = cur_sum + arr [ i ] ; if ( cur_sum - sum == 0 ) { start = 0 ; end = i ; break ; } if ( hashMap . ContainsKey ( cur_sum - sum ) ) { start = hashMap [ cur_sum - sum ] + 1 ; end = i ; break ; } hashMap [ cur_sum ] = i ; } if ( end == - 1 ) { Console . WriteLine ( " No ▁ subarray ▁ with ▁ given ▁ sum ▁ exists " ) ; } else { Console . WriteLine ( " Sum ▁ found ▁ between ▁ indexes ▁ " + start + " ▁ to ▁ " + end ) ; } } public static void Main ( string [ ] args ) { int [ ] arr = new int [ ] { 10 , 2 , - 2 , - 20 , 10 } ; int n = arr . Length ; int sum = - 10 ; subArraySum ( arr , n , sum ) ; } }

Index/key variables: cur_sum, i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class Node { public int data ; public Node left , right ; public Node ( int item ) { data = item ; left = right = null ; } } public class BinaryTree { public Node root1 , root2 ; public virtual bool identicalTrees ( Node a , Node b ) { if ( a == null && b == null ) { return true ; } if ( a != null && b != null ) { return ( a . data == b . data && identicalTrees ( a . left , b . left ) && identicalTrees ( a . right , b . right ) ) ; } return false ; } public static void Main ( string [ ] args ) { BinaryTree tree = new BinaryTree ( ) ; tree . root1 = new Node ( 1 ) ; tree . root1 . left = new Node ( 2 ) ; tree . root1 . right = new Node ( 3 ) ; tree . root1 . left . left = new Node ( 4 ) ; tree . root1 . left . right = new Node ( 5 ) ; tree . root2 = new Node ( 1 ) ; tree . root2 . left = new Node ( 2 ) ; tree . root2 . right = new Node ( 3 ) ; tree . root2 . left . left = new Node ( 4 ) ; tree . root2 . left . right = new Node ( 5 ) ; if ( tree . identicalTrees ( tree . root1 , tree . root2 ) ) { Console . WriteLine ( " Both ▁ trees ▁ are ▁ identical " ) ; } else { Console . WriteLine ( " Trees ▁ are ▁ not ▁ identical " ) ; } } }

Class/struct names: BinaryTree, Node
C# program:
using System ; class GFG { static int maxn = 100005 ; static int [ , ] BITree = new int [ 26 , maxn ] ; static int N ; static void update_BITree ( int index , char C , int val ) { while ( index <= N ) { BITree [ C - ' a ' , index ] += val ; index += ( index & - index ) ; } } static int sum_BITree ( int index , char C ) { int s = 0 ; while ( index > 0 ) { s += BITree [ C - ' a ' , index ] ; index -= ( index & - index ) ; } return s ; } static void buildTree ( String str ) { for ( int i = 1 ; i <= N ; i ++ ) { update_BITree ( i , str [ i ] , 1 ) ; } Console . WriteLine ( ) ; } static char printchar ( String str , int l , int r , int k ) { int count = 0 ; char ans = ( char ) 0 ; for ( char C = ' z ' ; C >= ' a ' ; C -- ) { int times = sum_BITree ( r , C ) - sum_BITree ( l - 1 , C ) ; count += times ; if ( count >= k ) { ans = C ; break ; } } return ans ; } static void updateTree ( String str , int pos , char s ) { int index = pos ; update_BITree ( index , str [ index ] , - 1 ) ; str = str . Substring ( 0 , index ) + s + str . Substring ( index + 1 ) ; update_BITree ( index , s , 1 ) ; } public static void Main ( String [ ] args ) { String str = " abcddef " ; N = str . Length ; str = ' / ' + str ; int Q = 3 ; buildTree ( str ) ; Console . Write ( printchar ( str , 1 , 2 , 2 ) + " STRNEWLINE " ) ; updateTree ( str , 4 , ' g ' ) ; Console . Write ( printchar ( str , 1 , 5 , 4 ) + " STRNEWLINE " ) ; } }

Index/key variables: i, index
Accumulator variables: C, count, i, index, s
Iterator variables: C, i
Class/struct names: GFG
C# program:
using System ; using System . Text ; class GFG { public static String generatePassword ( String [ ] s , char T ) { StringBuilder result = new StringBuilder ( ) ; foreach ( String currentString in s ) { String [ ] person = currentString . Split ( ' : ' ) ; String name = person [ 0 ] ; String number = person [ 1 ] ; int n = name . Length ; int max = 0 ; for ( int i = 0 ; i < number . Length ; i ++ ) { int temp = Int32 . Parse ( String . Join ( " " , number [ i ] ) ) ; if ( temp > max && temp <= n ) max = temp ; } if ( max == 0 ) result . Append ( T ) ; else result . Append ( String . Join ( " " , name [ max - 1 ] ) ) ; } return result . ToString ( ) ; } public static void Main ( String [ ] args ) { String [ ] arr = { " Geeks : 89167" , " gfg : 68795" } ; char T = ' X ' ; Console . WriteLine ( generatePassword ( arr , T ) ) ; } }

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