dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; using System . Collections . Generic ; class GFG { static void findMissingBinaryString ( string [ ] nums , int N ) { HashSet < string > s = new HashSet < string > ( ) ; int counter = 0 ; foreach ( string str in nums ) { s . Add ( str ) ; } int total = ( int ) Math . Pow ( 2 , N ) ; for ( int i = 0 ; i < total ; i ++ ) { string num = " " ; for ( int j = N - 1 ; j >= 0 ; j -- ) { if ( ( i & ( 1 << j ) ) > 0 ) { num += '1' ; } else { num += '0' ; } } if ( s . Contains ( num ) ) { counter ++ ; continue ; } else { Console . Write ( num + " , ▁ " ) ; } } if ( counter == total ) { Console . Write ( " - 1" ) ; } } public static void Main ( string [ ] args ) { int N = 3 ; string [ ] arr = { "101" , "111" , "001" , "011" , "100" , "110" } ; findMissingBinaryString ( arr , N ) ; } }

Accumulator variables: counter, i, j, num
Iterator variables: i, j, str
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; public class GFG { class pair { public int first , second ; public pair ( int first , int second ) { this . first = first ; this . second = second ; } } static int n = 6 ; static int m = 6 ; static int [ ] dx = { 0 , 1 , - 1 , 0 } ; static int [ ] dy = { 1 , 0 , 0 , - 1 } ; static int [ , ] visited = new int [ n , m ] ; static int COUNT ; static bool is_valid ( int x , int y , int [ , ] matrix ) { if ( x < n && y < m && x >= 0 && y >= 0 ) { if ( visited [ x , y ] == 0 && matrix [ x , y ] == 1 ) return true ; else return false ; } else return false ; } static Dictionary < int , int > mp = new Dictionary < int , int > ( ) ; static void findComponentSize ( int [ , ] matrix ) { for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { if ( visited [ i , j ] == 0 && matrix [ i , j ] == 1 ) { COUNT = 0 ; List < pair > q = new List < pair > ( ) ; q . Add ( new pair ( i , j ) ) ; visited [ i , j ] = 1 ; while ( q . Count > 0 ) { pair p = q [ 0 ] ; q . RemoveAt ( ) ; int x = p . first , y = p . second ; COUNT ++ ; for ( int k = 0 ; k < 4 ; k ++ ) { int newX = x + dx [ k ] ; int newY = y + dy [ k ] ; if ( is_valid ( newX , newY , matrix ) ) { q . Add ( new pair ( newX , newY ) ) ; visited [ newX , newY ] = 1 ; } } } if ( mp . ContainsKey ( COUNT ) ) { mp [ COUNT ] += 1 ; } else { mp . Add ( COUNT , 1 ) ; } } } } } public static void Main ( ) { int [ , ] matrix = new int [ , ] { { 1 , 1 , 1 , 1 , 1 , 1 } , { 1 , 1 , 0 , 0 , 0 , 0 } , { 0 , 0 , 0 , 1 , 1 , 1 } , { 0 , 0 , 0 , 1 , 1 , 1 } , { 0 , 0 , 1 , 0 , 0 , 0 } , { 1 , 0 , 0 , 0 , 0 , 0 } } ; int [ ] queries = { 6 , 1 , 8 , 2 } ; int N = queries . Length ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { visited [ i , j ] = 0 ; } } findComponentSize ( matrix ) ; for ( int i = 0 ; i < N ; i ++ ) if ( mp . ContainsKey ( queries [ i ] ) != false ) Console . Write ( mp [ queries [ i ] ] + " ▁ " ) ; } }

Index/key variables: COUNT, i, k
Accumulator variables: COUNT, i, j, k
Iterator variables: i, j, k
Class/struct names: GFG, pair
C# program:
using System ; public class GFG { static bool check ( int [ ] a , int [ ] b , int k , int x ) { int sum = 0 ; for ( int i = 0 ; i < a . Length ; i ++ ) { sum = sum + ( int ) Math . Pow ( Math . Max ( a [ i ] - x , 0 ) , b [ i ] ) ; } if ( sum <= k ) return true ; else return false ; } for ( int i = 0 ; i < a . Length ; ++ ) { = + ( int ) Math . Pow ( Math . Max ( a [ i ] - x , 0 ) , b [ i ] ) ; } if ( sum <= k ) return true ; else return false ; } static int ( int [ ] a , int [ ] b , int n , int k ) { int l = 0 , u = ( int ) 1e9 ; while ( l < u ) { int m = ( l + u ) / 2 ; if ( check ( a , b , k , m ) ) u = m ; else l = m + 1 ; } return l ; } public static void ( String [ ] args ) { int n = 5 ; int k = 12 ; int [ ] a = { 2 , 1 , 4 , 3 , 5 } ; int [ ] b = { 4 , 3 , 2 , 3 , 1 } ; Console . WriteLine ( findMin ( a , b , n , k ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int getPairsCount ( int [ ] arr , int n ) { int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = arr [ i ] - ( i % arr [ i ] ) ; j < n ; j += arr [ i ] ) { if ( i < j && ( arr [ i ] * arr [ j ] ) == Math . Abs ( i - j ) ) { count ++ ; } } } return count ; } public static void Main ( ) { int [ ] arr = { 1 , 1 , 2 , 4 } ; int N = arr . Length ; Console . Write ( getPairsCount ( arr , N ) ) ; } }

Index/key variables: i, j
Accumulator variables: count, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { public static void mostFrequent ( int [ ] arr , int N ) { int [ ] ans = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { int [ ] count = new int [ N ] ; int best = 1 ; for ( int j = i ; j < N ; j ++ ) { count [ arr [ j ] - 1 ] ++ ; if ( best > 0 ) { if ( ( count [ arr [ j ] - 1 ] > count [ best - 1 ] ) || ( count [ arr [ j ] - 1 ] == count [ best - 1 ] && arr [ j ] < best ) ) { best = arr [ j ] ; } ans [ best - 1 ] ++ ; } } } for ( int i = 0 ; i < N ; i ++ ) Console . Write ( ans [ i ] + " ▁ " ) ; } public static void Main ( ) { int [ ] arr = { 2 , 1 , 2 , 3 } ; int N = arr . Length ; mostFrequent ( arr , N ) ; } }

Index/key variables: N, i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int countElement ( int [ ] arr , int N ) { int count = 1 ; Dictionary < int , int > m = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { if ( m . ContainsKey ( arr [ i ] ) ) m [ arr [ i ] ] ++ ; else m . Add ( arr [ i ] , 1 ) ; } for ( int i = 0 ; i < N ; i ++ ) { int lg = ( int ) Math . Log ( arr [ i ] ) ; int p = ( int ) Math . Pow ( 2 , lg ) ; if ( m . ContainsKey ( p ) ) { count ++ ; } } return count ; } public static void Main ( ) { int [ ] arr = { 3 , 4 , 6 , 9 } ; int N = arr . Length ; Console . Write ( countElement ( 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 int lower_bound ( int [ ] a , int low , int high , long element ) { while ( low < high ) { int middle = low + ( high - low ) / 2 ; if ( element > a [ middle ] ) low = middle + 1 ; else high = middle ; } return low ; } static int maximumIntersections ( int [ , ] arr , int N ) { int count = 0 ; int [ ] L = new int [ N ] ; int [ ] R = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { L [ i ] = arr [ i , 0 ] ; R [ i ] = arr [ i , 1 ] ; } Array . Sort ( L ) ; Array . Sort ( R ) ; for ( int i = 0 ; i < N ; i ++ ) { int l = arr [ i , 0 ] ; int r = arr [ i , 1 ] ; int x = lower_bound ( L , 0 , N , l ) ; int y = N - lower_bound ( R , 0 , N , r + 1 ) ; int cnt = x + y ; cnt = N - cnt - 1 ; count = Math . Max ( count , cnt ) ; } return count ; } public static void Main ( ) { int [ , ] arr = new int [ 3 , 2 ] { { 1 , 6 } , { 5 , 5 } , { 2 , 3 } } ; int N = 3 ; Console . Write ( maximumIntersections ( arr , N ) ) ; } }

Index/key variables: N, i, middle
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class Node { public int data ; public Node next ; public Node ( int x ) { public Node ( int x ) { data = x ; next = null ; } } public class GFG { static Node head1 = null ; static Node head2 = null ; static Node intersectingNode ( Node headA , Node headB ) { Node a = headA ; while ( a != null ) { a . data *= - 1 ; a = a . next ; } Node b = headB ; while ( b != null ) { if ( b . data < 0 ) break ; b = b . next ; } return b ; } static void formLinkList ( ) { head1 = new Node ( 3 ) ; head1 . next = new Node ( 6 ) ; head1 . next . next = new Node ( 9 ) ; head1 . next . next . next = new Node ( 15 ) ; head1 . next . next . next . next = new Node ( 30 ) ; head2 = new Node ( 10 ) ; head2 . next = head1 . next . next . next ; return ; } static public void Main ( ) { formLinkList ( ) ; Console . WriteLine ( Math . Abs ( intersectingNode ( head1 , head2 ) . data ) ) ; } }

Accumulator variables: data
Class/struct names: GFG, Node
C# program:
using System ; using System . Collections . Generic ; class GFG { class TreeNode { public int val ; public TreeNode left , right ; } ; static TreeNode newNode ( int v ) { TreeNode temp = new TreeNode ( ) ; temp . val = v ; temp . left = temp . right = null ; return temp ; } static bool isInc ( TreeNode root ) { Queue < TreeNode > que = new Queue < TreeNode > ( ) ; que . Enqueue ( root ) ; while ( true ) { int len = que . Count ; if ( len == 0 ) break ; TreeNode pre = que . Peek ( ) ; while ( len > 0 ) { TreeNode temp = que . Peek ( ) ; que . Dequeue ( ) ; if ( pre . val > temp . val ) return false ; pre = temp ; if ( temp . left != null ) que . Enqueue ( temp . left ) ; if ( temp . right != null ) que . Enqueue ( temp . right ) ; len -= 1 ; } } return true ; } static void levelOrder ( TreeNode root ) { Queue < TreeNode > que = new Queue < TreeNode > ( ) ; que . Enqueue ( root ) ; while ( true ) { int len = que . Count ; if ( len == 0 ) break ; while ( len > 0 ) { TreeNode temp = que . Peek ( ) ; que . Dequeue ( ) ; Console . Write ( temp . val + " ▁ " ) ; if ( temp . left != null ) que . Enqueue ( temp . left ) ; if ( temp . right != null ) que . Enqueue ( temp . right ) ; len -= 1 ; } Console . Write ( " STRNEWLINE " ) ; } Console . Write ( " STRNEWLINE " ) ; } static void makeInc ( TreeNode root ) { Queue < TreeNode > que = new Queue < TreeNode > ( ) ; que . Enqueue ( root ) ; while ( true ) { int len = que . Count ; if ( len == 0 ) break ; int prev = - 1 ; while ( len > 0 ) { TreeNode temp = que . Peek ( ) ; que . Dequeue ( ) ; int optEle = temp . val ; string strEle = optEle . ToString ( ) ; bool flag = true ; int yy = strEle . Length ; for ( int idx = 0 ; idx < strEle . Length ; idx ++ ) { string s1 = strEle . Substring ( idx , yy - idx ) ; string s2 = strEle . Substring ( 0 , idx ) ; string s = String . Concat ( s1 , s2 ) ; int ls = Int32 . Parse ( s ) ; if ( ls >= prev && flag ) { optEle = ls ; flag = false ; } if ( ls >= prev ) optEle = Math . Min ( optEle , ls ) ; } temp . val = optEle ; prev = temp . val ; if ( temp . left != null ) que . Enqueue ( temp . left ) ; if ( temp . right != null ) que . Enqueue ( temp . right ) ; len -= 1 ; } } if ( isInc ( root ) == true ) levelOrder ( root ) ; else Console . Write ( - 1 ) ; } public static void Main ( ) { TreeNode root = newNode ( 341 ) ; root . left = newNode ( 241 ) ; root . right = newNode ( 123 ) ; root . left . left = newNode ( 324 ) ; root . left . right = newNode ( 235 ) ; root . right . right = newNode ( 161 ) ; makeInc ( root ) ; } }

Accumulator variables: idx, len
Iterator variables: idx
Boolean variables: flag
Class/struct names: GFG, TreeNode
C# program:
using System . Collections . Generic ; using System ; public class Node { public int data ; public Node left , right ; public Node ( int item ) { data = item ; left = right ; } } public class BinaryTree { Node root ; void reverseLevelOrder ( Node node ) { Stack < Node > S = new Stack < Node > ( ) ; Queue < Node > Q = new Queue < Node > ( ) ; Q . Enqueue ( node ) ; while ( Q . Count > 0 ) { node = Q . Peek ( ) ; Q . Dequeue ( ) ; S . Push ( node ) ; if ( node . right != null ) Q . Enqueue ( node . right ) ; if ( node . left != null ) Q . Enqueue ( node . left ) ; } while ( S . Count > 0 ) { node = S . Peek ( ) ; Console . Write ( node . data + " ▁ " ) ; S . Pop ( ) ; } } public static void Main ( ) { BinaryTree tree = new BinaryTree ( ) ; tree . root = new Node ( 1 ) ; tree . root . left = new Node ( 2 ) ; tree . root . right = new Node ( 3 ) ; tree . root . left . left = new Node ( 4 ) ; tree . root . left . right = new Node ( 5 ) ; tree . root . right . left = new Node ( 6 ) ; tree . root . right . right = new Node ( 7 ) ; Console . WriteLine ( " Level ▁ Order ▁ traversal ▁ of ▁ binary ▁ tree ▁ is ▁ : " ) ; tree . reverseLevelOrder ( tree . root ) ; } }

Class/struct names: BinaryTree, Node
C# program:
using System ; using System . Collections . Generic ; class GFG { static void removeDuplicateCharacters ( string [ ] arr ) { HashSet < int > cset = new HashSet < int > ( ) ; int n = arr . Length ; List < string > Out = new List < string > ( ) ; foreach ( string str in arr ) { string out_curr = " " ; foreach ( char ch in str . ToCharArray ( ) ) { if ( cset . Contains ( ch ) ) continue ; out_curr += ch ; cset . Add ( ch ) ; } if ( out_curr . Length != 0 ) Out . Add ( out_curr ) ; } for ( int i = 0 ; i < Out . Count ; i ++ ) { Console . Write ( Out [ i ] + " ▁ " ) ; } } static public void Main ( ) { string [ ] arr = { " Geeks " , " For " , " Geeks " , " Post " } ; removeDuplicateCharacters ( arr ) ; } }

Index/key variables: i
Accumulator variables: i, out_curr
Iterator variables: ch, i, str
Class/struct names: GFG
C# program:
using System ; class GFG { static bool isPrime ( int n ) { if ( n <= 1 ) return false ; if ( n <= 3 ) return true ; if ( n % 2 == 0 n % 3 == 0 ) return false ; for ( int i = 5 ; i * i <= n ; i = i + 6 ) if ( n % i == 0 || n % ( i + 2 ) == 0 ) return false ; return true ; } static void primeFactorSum ( int [ ] arr , int n , int k ) { int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( k % arr [ i ] == 0 && isPrime ( arr [ i ] ) ) { sum = sum + arr [ i ] ; } } Console . Write ( sum ) ; } public static void Main ( string [ ] args ) { int [ ] arr = { 1 , 2 , 3 , 5 , 6 , 7 , 15 } ; int N = arr . Length ; int K = 35 ; primeFactorSum ( arr , N , K ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int minOperations ( int [ ] nums , int x ) { int sum = 0 ; for ( int i = 0 ; i < x ; i ++ ) sum += nums [ i ] ; if ( sum < x ) return - 1 ; int ans = Int32 . MaxValue ; int l = nums . Length - 1 , r = nums . Length ; x -= sum ; while ( l >= 0 ) { if ( x <= 0 ) { x += nums [ l ] ; l -= 1 ; } if ( x > 0 ) { r -= 1 ; x -= nums [ r ] ; } if ( x == 0 ) { ans = Math . Min ( ans , ( l + 1 ) + ( nums . Length - r ) ) ; } } if ( ans < Int32 . MaxValue ) return ans ; else return - 1 ; } public static void Main ( ) { int [ ] nums = { 1 , 1 , 4 , 2 , 3 } ; int x = 5 ; Console . Write ( minOperations ( nums , x ) ) ; } }

Index/key variables: i, l, r
Accumulator variables: i, l, r, sum, x
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void evenproduct ( int [ ] arr , int length ) { int total_subarray = length * ( length + 1 ) / 2 ; int total_odd = 0 ; int count_odd = 0 ; for ( int i = 0 ; i < arr . Length ; ++ i ) { if ( arr [ i ] % 2 == 0 ) { count_odd = 0 ; } else { ++ count_odd ; total_odd += count_odd ; } } Console . WriteLine ( total_subarray - total_odd ) ; } public static void Main ( string [ ] args ) { int [ ] arr = { 7 , 5 , 4 , 9 } ; int length = arr . Length ; evenproduct ( arr , length ) ; } }

Index/key variables: i
Accumulator variables: total_odd
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static bool checkGroup ( List < int > arr ) { if ( arr . Count <= 2 ) return true ; int corner = arr [ 0 ] + arr [ arr . Count - 1 ] ; int xorSum = 0 ; for ( int i = 0 ; i < arr . Count - 1 ; i ++ ) xorSum += ( arr [ i ] ^ arr [ i + 1 ] ) ; if ( corner == 0 ) if ( xorSum > 2 ) return false ; else if ( corner == 1 ) if ( xorSum > 1 ) return false ; else if ( xorSum > 0 ) return false ; return true ; } static bool isInGroupUtil ( int [ , ] mat ) { for ( int i = 0 ; i < mat . GetLength ( 1 ) ; i ++ ) { List < int > arr = new List < int > ( ) ; for ( int j = 0 ; j < mat . GetLength ( 0 ) ; j ++ ) { arr . Add ( mat [ i , j ] ) ; } if ( ! checkGroup ( arr ) ) return false ; } return true ; } static void isInGroup ( int [ , ] mat ) { bool ans = isInGroupUtil ( mat ) ; if ( ans ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } static void Main ( ) { int [ , ] mat = { { 0 , 1 , 1 , 0 } , { 1 , 1 , 0 , 0 } , { 0 , 0 , 0 , 1 } , { 1 , 1 , 1 , 0 } } ; isInGroup ( mat ) ; } }

Index/key variables: i
Accumulator variables: i, j, xorSum
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int productOfDigits ( int N ) { int product = 1 ; while ( N != 0 ) { product = product * ( N % 10 ) ; N = N / 10 ; } return product ; } static void productOfDigitsK ( int N , int K ) { int flag = 0 ; for ( int i = 1 ; i <= N ; ++ i ) { if ( K == productOfDigits ( i ) ) { Console . Write ( i + " ▁ " ) ; flag = 1 ; } } if ( flag == 0 ) Console . WriteLine ( - 1 ) ; } static public void Main ( ) { int N = 500 , K = 10 ; productOfDigitsK ( N , K ) ; } }

Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFg { static void minimiseDifference ( List < int > arr , int K ) { int N = arr . Count ; int [ ] maxSuffix = new int [ N + 1 ] ; int [ ] minSuffix = new int [ N + 1 ] ; maxSuffix [ N ] = - 1000000000 ; minSuffix [ N ] = 1000000000 ; maxSuffix [ N - 1 ] = arr [ N - 1 ] ; minSuffix [ N - 1 ] = arr [ N - 1 ] ; for ( int i = N - 2 ; i >= 0 ; -- i ) { maxSuffix [ i ] = Math . Max ( maxSuffix [ i + 1 ] , arr [ i ] ) ; minSuffix [ i ] = Math . Min ( minSuffix [ i + 1 ] , arr [ i ] ) ; } int maxPrefix = arr [ 0 ] ; int minPrefix = arr [ 0 ] ; int minDiff = maxSuffix [ K ] - minSuffix [ K ] ; for ( int i = 1 ; i < N ; ++ i ) { if ( i + K <= N ) { int maximum = Math . Max ( maxSuffix [ i + K ] , maxPrefix ) ; int minimum = Math . Min ( minSuffix [ i + K ] , minPrefix ) ; minDiff = Math . Min ( minDiff , maximum - minimum ) ; } maxPrefix = Math . Max ( maxPrefix , arr [ i ] ) ; minPrefix = Math . Min ( minPrefix , arr [ i ] ) ; } Console . WriteLine ( minDiff ) ; } public static void Main ( ) { List < int > arr = new List < int > ( ) { 4 , 5 , 8 , 9 , 1 , 2 } ; int K = 2 ; minimiseDifference ( arr , K ) ; } }

Index/key variables: K, N, i
Iterator variables: i
Class/struct names: GFg
C# program:
using System ; class GFG { static void longestSubstring ( string s , int k ) { int ans = 0 ; int [ ] freq = new int [ 26 ] ; int n = s . Length ; for ( int i = 0 ; i < n ; i ++ ) freq [ s [ i ] - ' a ' ] ++ ; int unique = 0 ; for ( int i = 0 ; i < 26 ; i ++ ) if ( freq [ i ] != 0 ) unique ++ ; for ( int curr_unique = 1 ; curr_unique <= unique ; curr_unique ++ ) { for ( int i = 0 ; i < freq . Length ; i ++ ) { freq [ i ] = 0 ; } int start = 0 , end = 0 ; int cnt = 0 , count_k = 0 ; while ( end < n ) { if ( cnt <= curr_unique ) { int ind = s [ end ] - ' a ' ; if ( freq [ ind ] == 0 ) cnt ++ ; freq [ ind ] ++ ; if ( freq [ ind ] == k ) count_k ++ ; end ++ ; } else { int ind = s [ start ] - ' a ' ; if ( freq [ ind ] == k ) count_k -- ; freq [ ind ] -- ; if ( freq [ ind ] == 0 ) cnt -- ; start ++ ; } if ( cnt == curr_unique && count_k == curr_unique ) ans = Math . Max ( ans , end - start ) ; } } Console . Write ( ans ) ; } public static void Main ( ) { string S = " aabbba " ; int K = 3 ; longestSubstring ( S , K ) ; } }

Index/key variables: end, i, ind, start
Accumulator variables: cnt, count_k, curr_unique, end, i, start, unique
Iterator variables: curr_unique, i
Class/struct names: GFG
C# program:
using System ; public class GFG { static int [ ] dRow = { - 1 , 0 , 1 , 0 } ; static int [ ] dCol = { 0 , 1 , 0 , - 1 } ; static bool isValid ( bool [ , ] vis , int row , int col , int COL , int ROW ) { if ( row < 0 col < 0 col > COL - 1 row > ROW - 1 ) return false ; if ( vis [ row , col ] == true ) return false ; return true ; } static void DFSUtil ( int row , int col , int [ , ] grid , bool [ , ] vis , int M , int N ) { vis [ row , col ] = true ; Console . Write ( grid [ row , col ] + " ▁ " ) ; for ( int i = 0 ; i < 4 ; i ++ ) { int x = row + dRow [ i ] ; int y = col + dCol [ i ] ; if ( isValid ( vis , x , y , M , N ) ) DFSUtil ( x , y , grid , vis , M , N ) ; } } static void DFS ( int row , int col , int [ , ] grid , int M , int N ) { bool [ , ] vis = new bool [ M + 1 , N + 1 ] ; for ( int i = 0 ; i < M + 1 ; i ++ ) { for ( int j = 0 ; j < N + 1 ; j ++ ) { vis [ i , j ] = false ; } } DFSUtil ( 0 , 0 , grid , vis , M , N ) ; } public static void Main ( String [ ] args ) { int [ , ] grid = { { 1 , 2 , 3 , 4 } , { 5 , 6 , 7 , 8 } , { 9 , 10 , 11 , 12 } , { 13 , 14 , 15 , 16 } } ; int M = grid . GetLength ( 0 ) ; int N = grid . GetLength ( 1 ) ; DFS ( 0 , 0 , grid , M , N ) ; } }

Index/key variables: i
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int [ ] dRow = { - 1 , 0 , 1 , 0 } ; static int [ ] dCol = { 0 , 1 , 0 , - 1 } ; static List < List < bool > > vis ; static bool isValid ( int row , int col , int COL , int ROW ) { if ( row < 0 col < 0 col > COL - 1 row > ROW - 1 ) return false ; if ( vis [ row ] [ col ] == true ) return false ; return true ; } static void DFS_iterative ( int [ , ] grid , int M , int N ) { vis = new List < List < bool > > ( ) ; for ( int i = 0 ; i < M + 5 ; i ++ ) { vis . Add ( new List < bool > ( ) ) ; for ( int j = 0 ; j < N + 5 ; j ++ ) { vis [ i ] . Add ( false ) ; } } List < Tuple < int , int > > st = new List < Tuple < int , int > > ( ) ; st . Add ( new Tuple < int , int > ( 0 , 0 ) ) ; vis [ 0 ] [ 0 ] = true ; while ( st . Count > 0 ) { Tuple < int , int > p = st [ st . Count - 1 ] ; st . RemoveAt ( st . Count - 1 ) ; int row = p . Item1 ; int col = p . Item2 ; Console . Write ( grid [ row , col ] + " ▁ " ) ; for ( int i = 0 ; i < 4 ; i ++ ) { int x = row + dRow [ i ] ; int y = col + dCol [ i ] ; if ( isValid ( x , y , M , N ) ) { st . Add ( new Tuple < int , int > ( x , y ) ) ; vis [ x ] [ y ] = true ; } } } } static void Main ( ) { int [ , ] grid = { { 1 , 2 , 3 , 4 } , { 5 , 6 , 7 , 8 } , { 9 , 10 , 11 , 12 } , { 13 , 14 , 15 , 16 } } ; int M = 4 ; int N = 4 ; DFS_iterative ( grid , M , N ) ; } }

Index/key variables: col, i, row, x, y
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; public class GFG { static void minOps ( String s , int N ) { int ans = 0 ; for ( int i = 1 ; i < N ; i ++ ) { if ( s [ i ] != s [ i - 1 ] ) { ans ++ ; } } if ( ans % 2 == 1 ) { Console . Write ( ( ans - 1 ) / 2 ) ; return ; } Console . Write ( ans / 2 ) ; } public static void Main ( String [ ] args ) { String str = "01011100" ; int N = str . Length ; minOps ( str , N ) ; } }

Index/key variables: i
Accumulator variables: ans, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int MAX = 1000001 ; static bool [ ] prime = new bool [ MAX ] ; static int [ ] cntTriplet = new int [ MAX ] ; static void primeTriplet ( int N ) { for ( int i = 0 ; i <= N ; i ++ ) { prime [ i ] = true ; } prime [ 0 ] = prime [ 1 ] = false ; for ( int i = 2 ; i * i <= N ; i ++ ) { if ( prime [ i ] ) { for ( int j = i * i ; j <= N ; j += i ) { prime [ j ] = false ; } } } for ( int i = 3 ; i <= N ; i ++ ) { if ( prime [ i ] && prime [ i - 2 ] ) { cntTriplet [ i ] = cntTriplet [ i - 1 ] + 1 ; } else { cntTriplet [ i ] = cntTriplet [ i - 1 ] ; } } Console . WriteLine ( cntTriplet [ N ] ) ; } public static void Main ( String [ ] args ) { int N = 7 ; primeTriplet ( N ) ; } }

Index/key variables: MAX, N, i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; using System . Linq ; class GFG { static void OddOneOut ( int [ ] arr , int N ) { Dictionary < int , int > e = new Dictionary < int , int > ( ) ; Dictionary < int , int > o = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { if ( arr [ i ] % 2 == 0 ) { e [ arr [ i ] ] = i ; } else { o [ arr [ i ] ] = i ; } } if ( e . Count == 1 ) { Console . Write ( e . First ( ) . Value ) ; } else { Console . Write ( o . First ( ) . Value ) ; } } public static void Main ( string [ ] args ) { int [ ] arr = { 2 , 4 , 7 , 8 , 10 } ; int N = arr . Length ; OddOneOut ( arr , N ) ; } }

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