dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; class GFG { static int minDistance ( int [ ] a , int n ) { int max = - 1 , min = Int32 . MaxValue ; int min_index = - 1 , max_index = - 1 ; int min_dist = n + 1 ; for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] > max ) max = a [ i ] ; if ( a [ i ] < min ) min = a [ i ] ; } for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] == min ) min_index = i ; if ( a [ i ] == max ) max_index = i ; if ( min_index != - 1 && max_index != - 1 ) min_dist = Math . Min ( min_dist , Math . Abs ( min_index - max_index ) ) ; } return min_dist ; } public static void Main ( ) { int n = 12 ; int [ ] a = { 3 , 2 , 1 , 2 , 1 , 4 , 5 , 8 , 6 , 7 , 8 , 2 } ; Console . WriteLine ( minDistance ( a , n ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void printDiagonal ( int K , int N , int [ , ] M ) { int startrow , startcol ; if ( K - 1 < N ) { startrow = K - 1 ; startcol = 0 ; } else { startrow = N - 1 ; startcol = K - N ; } for ( ; startrow >= 0 && startcol < N ; startrow -- , startcol ++ ) { Console . Write ( M [ startrow , startcol ] + " ▁ " ) ; } } public static void Main ( String [ ] args ) { int N = 3 , K = 4 ; int [ , ] M = { { 4 , 7 , 8 } , { 9 , 2 , 3 } , { 0 , 4 , 1 } } ; printDiagonal ( K , N , M ) ; } }

Accumulator variables: startcol, startrow
Class/struct names: GFG
C# program:
using System ; class GFG { static void longestSubstring ( string str , char X , char Y ) { int N = str . Length ; int start = 0 ; int end = N - 1 ; int xPos = 0 ; int yPos = 0 ; while ( true ) { if ( str [ start ] == X ) { xPos = start ; break ; } start ++ ; } while ( true ) { if ( str [ end ] == Y ) { yPos = end ; break ; } end -- ; } int length = ( yPos - xPos ) + 1 ; Console . Write ( length ) ; } public static void Main ( ) { string str = " HASFJGHOGAKZZFEGA " ; char X = ' A ' , Y = ' Z ' ; longestSubstring ( str , X , Y ) ; } }

Index/key variables: end, start
Accumulator variables: end, start
Class/struct names: GFG
C# program:
using System ; class GFG { static int findParent ( int height , int node ) { int start = 1 ; int end = ( int ) Math . Pow ( 2 , height ) - 1 ; if ( end == node ) return - 1 ; while ( node >= 1 ) { end = end - 1 ; int mid = start + ( end - start ) / 2 ; if ( mid == node end == node ) { return ( end + 1 ) ; } else if ( node < mid ) { end = mid ; } else { start = mid ; } } return - 1 ; } public static void Main ( String [ ] args ) { int height = 4 ; int node = 6 ; int k = findParent ( height , node ) ; Console . Write ( k ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static void ReplaceElements ( int [ ] arr , int n ) { if ( n < 2 ) { Console . Write ( " Invalid ▁ Input " ) ; return ; } int firstSmallest = Int32 . MaxValue ; int secondSmallest = Int32 . MaxValue ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] < firstSmallest ) { secondSmallest = firstSmallest ; firstSmallest = arr [ i ] ; } else if ( arr [ i ] < secondSmallest && arr [ i ] != firstSmallest ) secondSmallest = arr [ i ] ; } for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] != firstSmallest ) arr [ i ] = firstSmallest ; else arr [ i ] = secondSmallest ; } for ( int i = 0 ; i < n ; ++ i ) { Console . Write ( arr [ i ] + " , ▁ " ) ; } } public static void Main ( ) { int [ ] arr = { 4 , 2 , 1 , 3 } ; int n = arr . Length ; ReplaceElements ( 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 countSubarrWithEqualZeroAndOne ( int [ ] arr , int n ) { Dictionary < int , int > mp = new Dictionary < int , int > ( ) ; int curr_sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { curr_sum += ( arr [ i ] == 0 ) ? - 1 : arr [ i ] ; if ( mp . ContainsKey ( curr_sum ) ) { var v = mp [ curr_sum ] ; mp . Remove ( curr_sum ) ; mp . Add ( curr_sum , ++ v ) ; } else mp . Add ( curr_sum , 1 ) ; } int count = 0 ; foreach ( KeyValuePair < int , int > itr in mp ) { if ( itr . Value > 1 ) count += ( ( itr . Value * ( itr . Value - 1 ) ) / 2 ) ; } if ( mp . ContainsKey ( 0 ) ) count += mp [ 0 ] ; return count ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 0 , 0 , 1 , 0 , 1 , 1 } ; int n = arr . Length ; Console . WriteLine ( " Count ▁ = ▁ " + countSubarrWithEqualZeroAndOne ( arr , n ) ) ; } }

Index/key variables: curr_sum, i
Accumulator variables: count, curr_sum, i
Iterator variables: i, itr
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int lenOfLongSubarr ( int [ ] arr , int n ) { Dictionary < int , int > um = new Dictionary < int , int > ( ) ; int sum = 0 , maxLen = 0 ; for ( int i = 0 ; i < n ; i ++ ) { sum += arr [ i ] == 0 ? - 1 : 1 ; if ( sum == 1 ) maxLen = i + 1 ; else if ( ! um . ContainsKey ( sum ) ) um . Add ( sum , i ) ; if ( um . ContainsKey ( sum - 1 ) ) { if ( maxLen < ( i - um [ sum - 1 ] ) ) maxLen = i - um [ sum - 1 ] ; } } return maxLen ; } public static void Main ( String [ ] args ) { int [ ] arr = { 0 , 1 , 1 , 0 , 0 , 1 } ; int n = arr . Length ; Console . WriteLine ( " Length ▁ = ▁ " + lenOfLongSubarr ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int maxSubarraySum ( int [ ] arr , int N , int K ) { HashSet < int > cum_set = new HashSet < int > ( ) ; cum_set . Add ( 0 ) ; int max_sum = Int32 . MinValue , cSum = 0 ; for ( int i = 0 ; i < N ; i ++ ) { cSum += arr [ i ] ; List < int > al = new List < int > ( ) ; int end = 0 ; foreach ( int it in cum_set ) { end = it ; al . Add ( it ) ; } al . Sort ( ) ; int sit = lower_bound ( al , cSum - K ) ; if ( sit != end ) max_sum = Math . Max ( max_sum , cSum - sit ) ; cum_set . Add ( cSum ) ; } return max_sum ; } static int lower_bound ( List < int > al , int x ) { int l = - 1 , r = al . Count ; while ( l + 1 < r ) { int m = ( l + r ) >> 1 ; if ( al [ m ] >= x ) r = m ; else l = m ; } return r ; } public static void Main ( string [ ] args ) { int [ ] arr = { 5 , - 2 , 6 , 3 , - 5 } ; int K = 15 ; int N = arr . Length ; Console . Write ( maxSubarraySum ( arr , N , K ) ) ; } }

Index/key variables: i, m
Accumulator variables: cSum, i
Iterator variables: i, it
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void printAllAPTriplets ( int [ ] arr , int n ) { List < int > s = new List < int > ( ) ; for ( int i = 0 ; i < n - 1 ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { int diff = arr [ j ] - arr [ i ] ; bool exists = s . Exists ( element => element == ( arr [ i ] - diff ) ) ; if ( exists ) Console . WriteLine ( arr [ i ] - diff + " ▁ " + arr [ i ] + " ▁ " + arr [ j ] ) ; } s . Add ( arr [ i ] ) ; } } static void Main ( ) { int [ ] arr = new int [ ] { 2 , 6 , 9 , 12 , 17 , 22 , 31 , 32 , 35 , 42 } ; int n = arr . Length ; printAllAPTriplets ( arr , n ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void findAllTriplets ( int [ ] arr , int n ) { for ( int i = 1 ; i < n - 1 ; i ++ ) { for ( int j = i - 1 , k = i + 1 ; j >= 0 && k < n ; ) { if ( arr [ j ] + arr [ k ] == 2 * arr [ i ] ) { Console . WriteLine ( arr [ j ] + " ▁ " + arr [ i ] + " ▁ " + arr [ k ] ) ; k ++ ; j -- ; } else if ( arr [ j ] + arr [ k ] < 2 * arr [ i ] ) k ++ ; else j -- ; } } } public static void Main ( ) { int [ ] arr = { 2 , 6 , 9 , 12 , 17 , 22 , 31 , 32 , 35 , 42 } ; int n = arr . Length ; findAllTriplets ( arr , n ) ; } }

Index/key variables: i, j, k
Accumulator variables: i, j, k
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; public class CheckForPath { public class Node { public int data ; public Node left , right ; public Node ( int data ) { this . data = data ; left = right = null ; } } ; public static bool existPath ( Node root , int [ ] arr , int index ) { if ( root == null ) { return arr . Length == 0 ; } if ( ( root . left == null && root . right == null ) && ( root . data == arr [ index ] && root . data == arr [ arr . Length - 1 ] ) ) { return true ; } return ( index < arr . Length && ( root . data == arr [ index ] && ( existPath ( root . left , arr , index + 1 ) || existPath ( root . right , arr , index + 1 ) ) ) ) ; } public static void Main ( ) { int [ ] arr = { 5 , 8 , 6 , 7 } ; Node root = new Node ( 5 ) ; root . left = new Node ( 3 ) ; root . right = new Node ( 8 ) ; root . left . left = new Node ( 2 ) ; root . left . right = new Node ( 4 ) ; root . left . left . left = new Node ( 1 ) ; root . right . left = new Node ( 6 ) ; root . right . left . right = new Node ( 7 ) ; if ( existPath ( root , arr , 0 ) ) { Console . Write ( " Path ▁ Exists " ) ; } else { Console . Write ( " Path ▁ does ▁ not ▁ Exist " ) ; } } }

Index/key variables: index
Class/struct names: CheckForPath, Node
C# program:
using System ; using System . Collections . Generic ; class GFG { static void findTriplets ( int [ ] a , int n , int sum ) { int i ; Array . Sort ( a ) ; bool flag = false ; for ( i = 0 ; i < n - 2 ; i ++ ) { if ( i == 0 a [ i ] > a [ i - 1 ] ) { int start = i + 1 ; int end = n - 1 ; int target = sum - a [ i ] ; while ( start < end ) { if ( start > i + 1 && a [ start ] == a [ start - 1 ] ) { start ++ ; continue ; } if ( end < n - 1 && a [ end ] == a [ end + 1 ] ) { end -- ; continue ; } if ( target == a [ start ] + a [ end ] ) { Console . Write ( " [ " + a [ i ] + " , " + a [ start ] + " , " + a [ end ] + " ] ▁ " ) ; flag = true ; start ++ ; end -- ; } else if ( target > ( a [ start ] + a [ end ] ) ) { start ++ ; } else { end -- ; } } } } if ( flag == false ) { Console . WriteLine ( " No ▁ Such ▁ Triplets ▁ Exist " ) ; } } static void Main ( ) { int [ ] a = { 12 , 3 , 6 , 1 , 6 , 9 } ; int n = a . Length ; int sum = 24 ; findTriplets ( a , n , sum ) ; } }

Index/key variables: end, i, start
Accumulator variables: end, i, start
Iterator variables: i
Boolean variables: flag
Class/struct names: GFG
C# program:
using System ; class GFG { static int m = 6 ; static int n = 4 ; static int linearCheck ( int [ , ] ar , int [ ] arr ) { for ( int i = 0 ; i < m ; i ++ ) { bool matched = true ; for ( int j = 0 ; j < n ; j ++ ) { if ( ar [ i , j ] != arr [ j ] ) { matched = false ; break ; } } if ( matched ) return i + 1 ; } return - 1 ; } static public void Main ( ) { int [ , ] mat = { { 0 , 0 , 1 , 0 } , { 10 , 9 , 22 , 23 } , { 40 , 40 , 40 , 40 } , { 43 , 44 , 55 , 68 } , { 81 , 73 , 100 , 132 } , { 100 , 75 , 125 , 133 } } ; int [ ] row = { 10 , 9 , 22 , 23 } ; Console . Write ( linearCheck ( mat , row ) ) ; } }

Index/key variables: j
Accumulator variables: i, j
Iterator variables: i, j
Boolean variables: matched
Class/struct names: GFG
C# program:
using System ; public class GFG { static int countTriplets ( int [ ] arr , int n , int m ) { int count = 0 ; for ( int i = 0 ; i < n - 2 ; i ++ ) for ( int j = i + 1 ; j < n - 1 ; j ++ ) for ( int k = j + 1 ; k < n ; k ++ ) if ( arr [ i ] * arr [ j ] * arr [ k ] == m ) count ++ ; return count ; } public static void Main ( ) { int [ ] arr = { 1 , 4 , 6 , 2 , 3 , 8 } ; int m = 24 ; Console . WriteLine ( countTriplets ( arr , arr . Length , m ) ) ; } }

Index/key variables: i, j, k
Accumulator variables: count, i, j, k
Iterator variables: i, j, k
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int countTriplets ( int [ ] arr , int n , int m ) { Dictionary < int , int > occ = new Dictionary < int , int > ( n ) ; for ( int i = 0 ; i < n ; i ++ ) occ . Add ( arr [ i ] , i ) ; int count = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { if ( ( arr [ i ] * arr [ j ] <= m ) && ( arr [ i ] * arr [ j ] != 0 ) && ( m % ( arr [ i ] * arr [ j ] ) == 0 ) ) { int check = m / ( arr [ i ] * arr [ j ] ) ; if ( check != arr [ i ] && check != arr [ j ] && occ . ContainsKey ( check ) && occ [ check ] > i && occ [ check ] > j ) count ++ ; } } } return count ; } static void Main ( ) { int [ ] arr = { 1 , 4 , 6 , 2 , 3 , 8 } ; int m = 24 ; Console . WriteLine ( countTriplets ( arr , arr . Length , m ) ) ; } }

Index/key variables: check, i, j
Accumulator variables: count, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int countPairs ( int [ ] arr , int n ) { int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) for ( int j = i + 1 ; j < n ; j ++ ) if ( arr [ i ] == arr [ j ] ) ans ++ ; return ans ; } public static void Main ( ) { int [ ] arr = { 1 , 1 , 2 } ; int n = arr . Length ; Console . WriteLine ( countPairs ( arr , n ) ) ; } }

Index/key variables: i, j
Accumulator variables: ans, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { public class pair { public int first , second ; public pair ( int a , int b ) { first = a ; second = b ; } } static void preCalculate ( int [ ] binary , int n , pair [ ] left ) { int count1 = 0 , count0 = 0 ; for ( int i = 0 ; i < n ; i ++ ) { left [ i ] . first = count1 ; left [ i ] . second = count0 ; if ( binary [ i ] != 0 ) count1 ++ ; else count0 ++ ; } } public static void Main ( String [ ] args ) { int [ ] binary = { 1 , 1 , 1 , 0 , 0 , 1 , 0 , 1 , 1 } ; int n = binary . Length ; pair [ ] left = new pair [ n ] ; for ( int i = 0 ; i < n ; i ++ ) left [ i ] = new pair ( 0 , 0 ) ; preCalculate ( binary , n , left ) ; int [ ] queries = { 0 , 1 , 2 , 4 } ; int q = queries . Length ; for ( int i = 0 ; i < q ; i ++ ) Console . WriteLine ( left [ queries [ i ] ] . first + " ▁ ones ▁ " + left [ queries [ i ] ] . second + " ▁ zeros STRNEWLINE " ) ; } }

Index/key variables: i, n
Accumulator variables: count0, count1, i
Iterator variables: i
Class/struct names: GFG, pair
C# program:
using System ; using System . Collections . Generic ; class GFG { public static int countPairs ( int [ ] arr , int n ) { Dictionary < int , int > hm = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( hm . ContainsKey ( arr [ i ] ) ) { int a = hm [ arr [ i ] ] ; hm . Remove ( arr [ i ] ) ; hm . Add ( arr [ i ] , a + 1 ) ; } else hm . Add ( arr [ i ] , 1 ) ; } int ans = 0 ; foreach ( var it in hm ) { int count = it . Value ; ans += ( count * ( count - 1 ) ) / 2 ; } return ans ; } public static void Main ( ) { int [ ] arr = new int [ ] { 1 , 2 , 3 , 1 } ; Console . WriteLine ( countPairs ( arr , arr . Length ) ) ; } }

Index/key variables: i
Accumulator variables: ans, i
Iterator variables: i, it
Class/struct names: GFG
C# program:
using System ; class GFG { public static int pos1 = - 1 ; public static int pos2 = - 1 ; public static bool equiSumUtil ( int [ ] arr ) { int n = arr . Length ; int [ ] pre = new int [ n ] ; int sum = 0 , i ; for ( i = 0 ; i < n ; i ++ ) { sum += arr [ i ] ; pre [ i ] = sum ; } int [ ] suf = new int [ n ] ; sum = 0 ; for ( i = n - 1 ; i >= 0 ; i -- ) { sum += arr [ i ] ; suf [ i ] = sum ; } int total_sum = sum ; int j = n - 1 ; i = 0 ; while ( i < j - 1 ) { if ( pre [ i ] == total_sum / 3 ) { pos1 = i ; } if ( suf [ j ] == total_sum / 3 ) { pos2 = j ; } if ( pos1 != - 1 && pos2 != - 1 ) { if ( suf [ pos1 + 1 ] - suf [ pos2 ] == total_sum / 3 ) { return true ; } else { return false ; } } if ( pre [ i ] < suf [ j ] ) { i ++ ; } else { j -- ; } } return false ; } public static void equiSum ( int [ ] arr ) { bool ans = equiSumUtil ( arr ) ; if ( ans ) { Console . Write ( " First ▁ Segment ▁ : ▁ " ) ; for ( int i = 0 ; i <= pos1 ; i ++ ) { Console . Write ( arr [ i ] + " ▁ " ) ; } Console . WriteLine ( ) ; Console . Write ( " Second ▁ Segment ▁ : ▁ " ) ; for ( int i = pos1 + 1 ; i < pos2 ; i ++ ) { Console . Write ( arr [ i ] + " ▁ " ) ; } Console . WriteLine ( ) ; Console . Write ( " Third ▁ Segment ▁ : ▁ " ) ; for ( int i = pos2 ; i < arr . Length ; i ++ ) { Console . Write ( arr [ i ] + " ▁ " ) ; } Console . WriteLine ( ) ; } else { Console . WriteLine ( " Array ▁ cannot ▁ be ▁ " + " divided ▁ into ▁ three ▁ equal ▁ sum ▁ segments " ) ; } } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 3 , 6 , 2 , 7 , 1 , 2 , 8 } ; equiSum ( arr ) ; } }

Index/key variables: i, j, n, pos2
Accumulator variables: i, j, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int p = 101 ; static int MOD = 1000000007 ; public class Query { public int L , R ; public Query ( int L , int R ) { this . L = L ; this . R = R ; } } ; static Boolean isPalindrome ( String str , int L , int R ) { while ( R > L ) { if ( str [ L ++ ] != str [ R -- ] ) { return ( false ) ; } } return ( true ) ; } static int modPow ( int Base , int exponent ) { if ( exponent == 0 ) { return 1 ; } if ( exponent == 1 ) { return Base ; } int temp = modPow ( Base , exponent / 2 ) ; if ( exponent % 2 == 0 ) { return ( temp % MOD * temp % MOD ) % MOD ; } else { return ( ( ( temp % MOD * temp % MOD ) % MOD ) * Base % MOD ) % MOD ; } } static int findMMI ( int n ) { return modPow ( n , MOD - 2 ) ; } static void computePrefixHash ( String str , int n , int [ ] prefix , int [ ] power ) { prefix [ 0 ] = 0 ; prefix [ 1 ] = str [ 0 ] ; for ( int i = 2 ; i <= n ; i ++ ) { prefix [ i ] = ( prefix [ i - 1 ] % MOD + ( str [ i - 1 ] % MOD * power [ i - 1 ] % MOD ) % MOD ) % MOD ; } return ; } static void computeSuffixHash ( String str , int n , int [ ] suffix , int [ ] power ) { suffix [ 0 ] = 0 ; suffix [ 1 ] = str [ n - 1 ] ; for ( int i = n - 2 , j = 2 ; i >= 0 && j <= n ; i -- , j ++ ) { suffix [ j ] = ( suffix [ j - 1 ] % MOD + ( str [ i ] % MOD * power [ j - 1 ] % MOD ) % MOD ) % MOD ; } return ; } static void queryResults ( String str , Query [ ] q , int m , int n , int [ ] prefix , int [ ] suffix , int [ ] power ) { for ( int i = 0 ; i <= m - 1 ; i ++ ) { int L = q [ i ] . L ; int R = q [ i ] . R ; long hash_LR = ( ( prefix [ R + 1 ] - prefix [ L ] + MOD ) % MOD * findMMI ( power [ L ] ) % MOD ) % MOD ; long reverse_hash_LR = ( ( suffix [ n - L ] - suffix [ n - R - 1 ] + MOD ) % MOD * findMMI ( power [ n - R - 1 ] ) % MOD ) % MOD ; if ( hash_LR == reverse_hash_LR ) { if ( isPalindrome ( str , L , R ) == true ) { Console . Write ( " The ▁ Substring ▁ [ { 0 } ▁ { 1 } ] ▁ is ▁ a ▁ " + " palindrome STRNEWLINE " , L , R ) ; } else { Console . Write ( " The ▁ Substring ▁ [ { 0 } ▁ { 1 } ] ▁ is ▁ not ▁ a ▁ " + " palindrome STRNEWLINE " , L , R ) ; } } else { Console . Write ( " The ▁ Substring ▁ [ { 0 } ▁ { 1 } ] ▁ is ▁ not ▁ a ▁ " + " palindrome STRNEWLINE " , L , R ) ; } } return ; } static void computePowers ( int [ ] power , int n ) { power [ 0 ] = 1 ; for ( int i = 1 ; i <= n ; i ++ ) { power [ i ] = ( power [ i - 1 ] % MOD * p % MOD ) % MOD ; } return ; } public static void Main ( String [ ] args ) { String str = " abaaabaaaba " ; int n = str . Length ; int [ ] power = new int [ n + 1 ] ; computePowers ( power , n ) ; int [ ] prefix = new int [ n + 1 ] ; int [ ] suffix = new int [ n + 1 ] ; computePrefixHash ( str , n , prefix , power ) ; computeSuffixHash ( str , n , suffix , power ) ; Query [ ] q = { new Query ( 0 , 10 ) , new Query ( 5 , 8 ) , new Query ( 2 , 5 ) , new Query ( 5 , 9 ) } ; int m = q . Length ; queryResults ( str , q , m , n , prefix , suffix , power ) ; } }

Index/key variables: L, i, j
Accumulator variables: L, R, i, j
Iterator variables: i
Class/struct names: GFG, Query
C# program:
using System ; public class GfG { class Node { public int data ; public Node left , right ; } static Node newNode ( int item ) { Node temp = new Node ( ) ; temp . data = item ; temp . left = null ; temp . right = null ; return temp ; } static int getLevel ( Node root , Node node , int level ) { if ( root == null ) return 0 ; if ( root == node ) return level ; int downlevel = getLevel ( root . left , node , level + 1 ) ; if ( downlevel != 0 ) return downlevel ; return getLevel ( root . right , node , level + 1 ) ; } static void printGivenLevel ( Node root , Node node , int level ) { if ( root == null level < 2 ) return ; if ( level == 2 ) { if ( root . left == node root . right == node ) return ; if ( root . left != null ) Console . Write ( root . left . data + " ▁ " ) ; if ( root . right != null ) Console . Write ( root . right . data + " ▁ " ) ; } else if ( level > 2 ) { printGivenLevel ( root . left , node , level - 1 ) ; printGivenLevel ( root . right , node , level - 1 ) ; } } static void printCousins ( Node root , Node node ) { int level = getLevel ( root , node , 1 ) ; printGivenLevel ( root , node , level ) ; } public static void Main ( String [ ] args ) { Node root = newNode ( 1 ) ; root . left = newNode ( 2 ) ; root . right = newNode ( 3 ) ; root . left . left = newNode ( 4 ) ; root . left . right = newNode ( 5 ) ; root . left . right . right = newNode ( 15 ) ; root . right . left = newNode ( 6 ) ; root . right . right = newNode ( 7 ) ; root . right . left . right = newNode ( 8 ) ; printCousins ( root , root . left . right ) ; } }

Class/struct names: GfG, Node
C# program:
using System ; public class GFG { public static int getRightMin ( int [ ] arr , int n ) { int min = arr [ 0 ] ; int rightMin = 0 ; int i = 1 ; while ( i < n ) { if ( arr [ i ] == min ) rightMin = i ; i *= 2 ; } i = rightMin + 1 ; while ( i < n && arr [ i ] == min ) { rightMin = i ; i ++ ; } return rightMin ; } public static int getLeftMax ( int [ ] arr , int n ) { int max = arr [ n - 1 ] ; int leftMax = n - 1 ; int i = n - 2 ; while ( i > 0 ) { if ( arr [ i ] == max ) leftMax = i ; i /= 2 ; } i = leftMax - 1 ; while ( i >= 0 && arr [ i ] == max ) { leftMax = i ; i -- ; } return leftMax ; } public static void Main ( ) { int [ ] arr = { 0 , 0 , 1 , 2 , 5 , 5 , 6 , 8 , 8 } ; int n = arr . Length ; Console . WriteLine ( " Minimum ▁ left ▁ : ▁ " + 0 ) ; Console . WriteLine ( " Minimum ▁ right ▁ : ▁ " + getRightMin ( arr , n ) ) ; Console . WriteLine ( " Maximum ▁ left ▁ : ▁ " + getLeftMax ( arr , n ) ) ; Console . WriteLine ( " Maximum ▁ right ▁ : ▁ " + ( n - 1 ) ) ; } }

Index/key variables: i
Accumulator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static int countNum ( int [ ] arr , int n ) { int count = 0 ; Array . Sort ( arr ) ; for ( int i = 0 ; i < n - 1 ; i ++ ) if ( arr [ i ] != arr [ i + 1 ] && arr [ i ] != arr [ i + 1 ] - 1 ) count += arr [ i + 1 ] - arr [ i ] - 1 ; return count ; } static public void Main ( ) { int [ ] arr = { 3 , 5 , 8 , 6 } ; int n = arr . Length ; Console . WriteLine ( countNum ( 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 void findElementsAfterDel ( int [ ] arr , int m , int [ ] del , int n , int k ) { Dictionary < int , int > mp = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < n ; ++ i ) { if ( mp . ContainsKey ( del [ i ] ) ) { mp [ del [ i ] ] ++ ; } else { mp [ del [ i ] ] = 1 ; } } List < int > heap = new List < int > ( ) ; for ( int i = 0 ; i < m ; ++ i ) { if ( mp . ContainsKey ( arr [ i ] ) ) { mp [ arr [ i ] ] -- ; if ( mp [ arr [ i ] ] == 0 ) mp . Remove ( arr [ i ] ) ; } else heap . Add ( arr [ i ] ) ; } heap . Sort ( ) ; for ( int i = 0 ; i < k ; ++ i ) { Console . Write ( heap [ 0 ] + " ▁ " ) ; heap . RemoveAt ( 0 ) ; } } static void Main ( ) { int [ ] array = { 5 , 12 , 33 , 4 , 56 , 12 , 20 } ; int m = array . Length ; int [ ] del = { 12 , 56 , 5 } ; int n = del . Length ; int k = 3 ; findElementsAfterDel ( array , m , del , n , k ) ; } }

Index/key variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int countNum ( int [ ] arr , int n ) { HashSet < int > s = new HashSet < int > ( ) ; int count = 0 , maxm = int . MinValue , minm = int . MaxValue ; for ( int i = 0 ; i < n ; i ++ ) { s . Add ( arr [ i ] ) ; if ( arr [ i ] < minm ) minm = arr [ i ] ; if ( arr [ i ] > maxm ) maxm = arr [ i ] ; } for ( int i = minm ; i <= maxm ; i ++ ) if ( ! s . Contains ( i ) ) count ++ ; return count ; } public static void Main ( String [ ] args ) { int [ ] arr = { 3 , 5 , 8 , 6 } ; int n = arr . Length ; Console . WriteLine ( countNum ( arr , n ) ) ; } }

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