dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; using System . Collections . Generic ; public class Node { public int data ; public Node left , right ; public Node ( int data ) { this . data = data ; left = right = null ; } } public class BinaryTree { Node root ; Node head ; void push ( Node node ) { node . right = head ; node . left = null ; if ( head != null ) head . left = node ; head = node ; } void printList ( Node node ) { while ( node != null ) { Console . Write ( node . data + " ▁ " ) ; node = node . right ; } } void spiralLevelOrder ( Node root ) { if ( root == null ) return ; LinkedList < Node > q = new LinkedList < Node > ( ) ; q . AddFirst ( root ) ; Stack < Node > stk = new Stack < Node > ( ) ; int level = 0 ; while ( q . Count != 0 ) { int nodeCount = q . Count ; if ( ( level & 1 ) % 2 != 0 ) { while ( nodeCount > 0 ) { Node node = q . First . Value ; q . RemoveFirst ( ) ; stk . Push ( node ) ; if ( node . left != null ) q . AddLast ( node . left ) ; if ( node . right != null ) q . AddLast ( node . right ) ; nodeCount -- ; } } else { while ( nodeCount > 0 ) { Node node = q . Last . Value ; q . RemoveLast ( ) ; stk . Push ( node ) ; if ( node . right != null ) q . AddFirst ( node . right ) ; if ( node . left != null ) q . AddFirst ( node . left ) ; nodeCount -- ; } } level ++ ; } while ( stk . Count != 0 ) { push ( stk . Peek ( ) ) ; stk . Pop ( ) ; } Console . WriteLine ( " Created ▁ DLL ▁ is ▁ : ▁ " ) ; printList ( head ) ; } public static void Main ( String [ ] args ) { 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 ) ; tree . root . left . left . left = new Node ( 8 ) ; tree . root . left . left . right = new Node ( 9 ) ; tree . root . left . right . left = new Node ( 10 ) ; tree . root . left . right . right = new Node ( 11 ) ; tree . root . right . left . right = new Node ( 13 ) ; tree . root . right . right . left = new Node ( 14 ) ; tree . spiralLevelOrder ( tree . root ) ; } }

Accumulator variables: level, nodeCount
Class/struct names: BinaryTree, Node
C# program:
using System ; using System . Collections . Generic ; class GFG { public static void reverseWords ( string str ) { Stack < char > st = new Stack < char > ( ) ; for ( int i = 0 ; i < str . Length ; ++ i ) { if ( str [ i ] != ' ▁ ' ) { st . Push ( str [ i ] ) ; } else { while ( st . Count > 0 ) { Console . Write ( st . Pop ( ) ) ; } Console . Write ( " ▁ " ) ; } } while ( st . Count > 0 ) { Console . Write ( st . Pop ( ) ) ; } } public static void Main ( string [ ] args ) { string str = " Geeks ▁ for ▁ Geeks " ; reverseWords ( str ) ; } }

Index/key variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int MAXN = 100005 ; public class pair { public int first , second ; public pair ( int first , int second ) { this . first = first ; this . second = second ; } } static void makeNext ( int [ ] arr , int n , int [ ] nextBig ) { Stack < pair > s = new Stack < pair > ( ) ; for ( int i = n - 1 ; i >= 0 ; i -- ) { nextBig [ i ] = i ; while ( s . Count != 0 && s . Peek ( ) . first < arr [ i ] ) s . Pop ( ) ; if ( s . Count != 0 ) nextBig [ i ] = s . Peek ( ) . second ; s . Push ( new pair ( arr [ i ] , i ) ) ; } } static void makePrev ( int [ ] arr , int n , int [ ] prevBig ) { Stack < pair > s = new Stack < pair > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { prevBig [ i ] = - 1 ; while ( s . Count != 0 && s . Peek ( ) . first < arr [ i ] ) s . Pop ( ) ; if ( s . Count != 0 ) prevBig [ i ] = s . Peek ( ) . second ; s . Push ( new pair ( arr [ i ] , i ) ) ; } } static int wrapper ( int [ ] arr , int n ) { int [ ] nextBig = new int [ MAXN ] ; int [ ] prevBig = new int [ MAXN ] ; int [ ] maxi = new int [ MAXN ] ; int ans = 0 ; makePrev ( arr , n , prevBig ) ; makeNext ( arr , n , nextBig ) ; for ( int i = 0 ; i < n ; i ++ ) if ( nextBig [ i ] != i ) maxi [ nextBig [ i ] - i ] = Math . Max ( maxi [ nextBig [ i ] - i ] , i - prevBig [ i ] ) ; for ( int i = 0 ; i < n ; i ++ ) ans += maxi [ i ] ; return ans ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 3 , 2 , 4 } ; int n = arr . Length ; Console . WriteLine ( wrapper ( arr , n ) ) ; } }

Index/key variables: MAXN, i
Accumulator variables: ans, i
Iterator variables: i
Class/struct names: GFG, pair
C# program:
using System ; using System . Collections . Generic ; class GFG { public static int getMaxArea ( int [ ] hist , int n ) { Stack < int > s = new Stack < int > ( ) ; int max_area = 0 ; int tp ; int area_with_top ; int i = 0 ; while ( i < n ) { if ( s . Count == 0 || hist [ s . Peek ( ) ] <= hist [ i ] ) { s . Push ( i ++ ) ; } else { tp = s . Peek ( ) ; s . Pop ( ) ; area_with_top = hist [ tp ] * ( s . Count == 0 ? i : i - s . Peek ( ) - 1 ) ; if ( max_area < area_with_top ) { max_area = area_with_top ; } } } while ( s . Count > 0 ) { tp = s . Peek ( ) ; s . Pop ( ) ; area_with_top = hist [ tp ] * ( s . Count == 0 ? i : i - s . Peek ( ) - 1 ) ; if ( max_area < area_with_top ) { max_area = area_with_top ; } } return max_area ; } public static void Main ( string [ ] args ) { int [ ] hist = new int [ ] { 6 , 2 , 5 , 4 , 5 , 1 , 6 } ; Console . WriteLine ( " Maximum ▁ area ▁ is ▁ " + getMaxArea ( hist , hist . Length ) ) ; } }

Index/key variables: i, tp
Accumulator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void towerOfHanoi ( int n , char from_rod , char to_rod , char aux_rod ) { if ( n == 1 ) { Console . WriteLine ( " Move ▁ disk ▁ 1 ▁ from ▁ rod ▁ " + from_rod + " ▁ to ▁ rod ▁ " + to_rod ) ; return ; } towerOfHanoi ( n - 1 , from_rod , aux_rod , to_rod ) ; Console . WriteLine ( " Move ▁ disk ▁ " + n + " ▁ from ▁ rod ▁ " + from_rod + " ▁ to ▁ rod ▁ " + to_rod ) ; towerOfHanoi ( n - 1 , aux_rod , to_rod , from_rod ) ; } public static void Main ( String [ ] args ) { int n = 4 ; towerOfHanoi ( n , ' A ' , ' C ' , ' B ' ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int [ ] arr = { 10 , 20 , 30 , 50 , 10 , 70 , 30 } ; static void printMaxOfMin ( int n ) { for ( int k = 1 ; k <= n ; k ++ ) { int maxOfMin = int . MinValue ; for ( int i = 0 ; i <= n - k ; i ++ ) { int min = arr [ i ] ; for ( int j = 1 ; j < k ; j ++ ) { if ( arr [ i + j ] < min ) min = arr [ i + j ] ; } if ( min > maxOfMin ) maxOfMin = min ; } Console . Write ( maxOfMin + " ▁ " ) ; } } public static void Main ( ) { printMaxOfMin ( arr . Length ) ; } }

Index/key variables: i
Accumulator variables: i, j, k
Iterator variables: i, j, k
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { public static int [ ] arr = new int [ ] { 10 , 20 , 30 , 50 , 10 , 70 , 30 } ; public static void printMaxOfMin ( int n ) { Stack < int > s = new Stack < int > ( ) ; int [ ] left = new int [ n + 1 ] ; int [ ] right = new int [ n + 1 ] ; for ( int i = 0 ; i < n ; i ++ ) { left [ i ] = - 1 ; right [ i ] = n ; } for ( int i = 0 ; i < n ; i ++ ) { while ( s . Count > 0 && arr [ s . Peek ( ) ] >= arr [ i ] ) { s . Pop ( ) ; } if ( s . Count > 0 ) { left [ i ] = s . Peek ( ) ; } s . Push ( i ) ; } while ( s . Count > 0 ) { s . Pop ( ) ; } for ( int i = n - 1 ; i >= 0 ; i -- ) { while ( s . Count > 0 && arr [ s . Peek ( ) ] >= arr [ i ] ) { s . Pop ( ) ; } if ( s . Count > 0 ) { right [ i ] = s . Peek ( ) ; } s . Push ( i ) ; } int [ ] ans = new int [ n + 1 ] ; for ( int i = 0 ; i <= n ; i ++ ) { ans [ i ] = 0 ; } for ( int i = 0 ; i < n ; i ++ ) { int len = right [ i ] - left [ i ] - 1 ; ans [ len ] = Math . Max ( ans [ len ] , arr [ i ] ) ; } for ( int i = n - 1 ; i >= 1 ; i -- ) { ans [ i ] = Math . Max ( ans [ i ] , ans [ i + 1 ] ) ; } for ( int i = 1 ; i <= n ; i ++ ) { Console . Write ( ans [ i ] + " ▁ " ) ; } } public static void Main ( string [ ] args ) { printMaxOfMin ( arr . Length ) ; } }

Index/key variables: i, len
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int N = 12 , ans ; static List < List < int > > tree = new List < List < int > > ( ) ; static int dfs ( int [ ] visit , int node ) { int num = 0 , temp = 0 ; visit [ node ] = 1 ; for ( int i = 0 ; i < tree [ node ] . Count ; i ++ ) { if ( visit [ tree [ node ] [ i ] ] == 0 ) { temp = dfs ( visit , tree [ node ] [ i ] ) ; if ( temp % 2 != 0 ) num += temp ; else ans ++ ; } } return num + 1 ; } static int minEdge ( int n ) { int [ ] visit = new int [ n + 2 ] ; ans = 0 ; dfs ( visit , 1 ) ; return ans ; } public static void Main ( String [ ] args ) { int n = 10 ; for ( int i = 0 ; i < n + 2 ; i ++ ) tree . Add ( new List < int > ( ) ) ; tree [ 1 ] . Add ( 3 ) ; tree [ 3 ] . Add ( 1 ) ; tree [ 1 ] . Add ( 6 ) ; tree [ 6 ] . Add ( 1 ) ; tree [ 1 ] . Add ( 2 ) ; tree [ 2 ] . Add ( 1 ) ; tree [ 3 ] . Add ( 4 ) ; tree [ 4 ] . Add ( 3 ) ; tree [ 6 ] . Add ( 8 ) ; tree [ 8 ] . Add ( 6 ) ; tree [ 2 ] . Add ( 7 ) ; tree [ 7 ] . Add ( 2 ) ; tree [ 2 ] . Add ( 5 ) ; tree [ 5 ] . Add ( 2 ) ; tree [ 4 ] . Add ( 9 ) ; tree [ 9 ] . Add ( 4 ) ; tree [ 4 ] . Add ( 10 ) ; tree [ 10 ] . Add ( 4 ) ; Console . WriteLine ( minEdge ( n ) ) ; } }

Index/key variables: i, node
Accumulator variables: ans, i, num
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static bool checkRedundancy ( String s ) { Stack < char > st = new Stack < char > ( ) ; char [ ] str = s . ToCharArray ( ) ; foreach ( char ch in str ) { if ( ch == ' ) ' ) { char top = st . Peek ( ) ; st . Pop ( ) ; bool flag = true ; while ( top != ' ( ' ) { if ( top == ' + ' top == ' - ' top == ' * ' top == ' / ' ) { flag = false ; } top = st . Peek ( ) ; st . Pop ( ) ; } if ( flag == true ) { return true ; } } else { st . Push ( ch ) ; } } return false ; } static void findRedundant ( String str ) { bool ans = checkRedundancy ( str ) ; if ( ans == true ) { Console . WriteLine ( " Yes " ) ; } else { Console . WriteLine ( " No " ) ; } } public static void Main ( String [ ] args ) { String str = " ( ( a + b ) ) " ; findRedundant ( str ) ; str = " ( a + ( b ) / c ) " ; findRedundant ( str ) ; str = " ( a + b * ( c - d ) ) " ; findRedundant ( str ) ; } }

Iterator variables: ch
Boolean variables: flag
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; public class GFG { static readonly int MAX_CHAR = 26 ; static bool adjSign ( String s , int i ) { if ( i == 0 ) return true ; if ( s [ i - 1 ] == ' - ' ) return false ; return true ; } static void eval ( String s , int [ ] v , bool add ) { Stack < Boolean > stk = new Stack < Boolean > ( ) ; stk . Push ( true ) ; int i = 0 ; while ( i < s . Length ) { if ( s [ i ] == ' + ' s [ i ] == ' - ' ) { i ++ ; continue ; } if ( s [ i ] == ' ( ' ) { if ( adjSign ( s , i ) ) stk . Push ( stk . Peek ( ) ) ; else stk . Push ( ! stk . Peek ( ) ) ; } else if ( s [ i ] == ' ) ' ) stk . Pop ( ) ; else { if ( stk . Peek ( ) ) v [ s [ i ] - ' a ' ] += ( adjSign ( s , i ) ? add ? 1 : - 1 : add ? - 1 : 1 ) ; else v [ s [ i ] - ' a ' ] += ( adjSign ( s , i ) ? add ? - 1 : 1 : add ? 1 : - 1 ) ; } i ++ ; } } static bool areSame ( String expr1 , String expr2 ) { int [ ] v = new int [ MAX_CHAR ] ; eval ( expr1 , v , true ) ; eval ( expr2 , v , false ) ; for ( int i = 0 ; i < MAX_CHAR ; i ++ ) if ( v [ i ] != 0 ) return false ; return true ; } public static void Main ( String [ ] args ) { String expr1 = " - ( a + b + c ) " , expr2 = " - a - b - c " ; if ( areSame ( expr1 , expr2 ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }

Index/key variables: MAX_CHAR, i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections ; public class GFG { static void test ( String expression , int index ) { int i ; if ( expression [ index ] != ' [ ' ) { Console . Write ( expression + " , ▁ " + index + " : ▁ - 1 STRNEWLINE " ) ; return ; } Stack st = new Stack ( ) ; for ( i = index ; i < expression . Length ; i ++ ) { if ( expression [ i ] == ' [ ' ) { st . Push ( ( int ) expression [ i ] ) ; } else if ( expression [ i ] == ' ] ' ) { st . Pop ( ) ; if ( st . Count == 0 ) { Console . Write ( expression + " , ▁ " + index + " : ▁ " + i + " STRNEWLINE " ) ; return ; } } } Console . Write ( expression + " , ▁ " + index + " : ▁ - 1 STRNEWLINE " ) ; } public static void Main ( ) { test ( " [ ABC [ 23 ] ] [89 ] " , 0 ) ; test ( " [ ABC [ 23 ] ] [89 ] " , 4 ) ; test ( " [ ABC [ 23 ] ] [89 ] " , 9 ) ; test ( " [ ABC [ 23 ] ] [89 ] " , 1 ) ; } }

Index/key variables: i, index
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GfG { class Node { public int data ; public Node left ; public Node right ; } static Node newNode ( int key ) { Node node = new Node ( ) ; node . data = key ; node . left = null ; node . right = null ; return node ; } static void convertTree ( Node root ) { if ( root == null ) return ; convertTree ( root . left ) ; convertTree ( root . right ) ; if ( root . left != null && root . right != null ) root . data = ( root . left . data ) & ( root . right . data ) ; } static void printInorder ( Node root ) { if ( root == null ) return ; printInorder ( root . left ) ; Console . Write ( root . data + " ▁ " ) ; printInorder ( root . right ) ; } public static void Main ( ) { Node root = newNode ( 0 ) ; root . left = newNode ( 1 ) ; root . right = newNode ( 0 ) ; root . left . left = newNode ( 0 ) ; root . left . right = newNode ( 1 ) ; root . right . left = newNode ( 1 ) ; root . right . right = newNode ( 1 ) ; Console . Write ( " Inorder ▁ traversal ▁ before ▁ conversion ▁ " ) ; printInorder ( root ) ; convertTree ( root ) ; Console . WriteLine ( ) ; Console . Write ( " Inorder ▁ traversal ▁ after ▁ conversion ▁ " ) ; printInorder ( root ) ; } }

Class/struct names: GfG, Node
C# program:
using System ; using System . Collections . Generic ; class GFG { static Boolean findDuplicateparenthesis ( String s ) { Stack < char > Stack = new Stack < char > ( ) ; char [ ] str = s . ToCharArray ( ) ; foreach ( char ch in str ) { if ( ch == ' ) ' ) { char top = Stack . Peek ( ) ; Stack . Pop ( ) ; int elementsInside = 0 ; while ( top != ' ( ' ) { elementsInside ++ ; top = Stack . Peek ( ) ; Stack . Pop ( ) ; } if ( elementsInside < 1 ) { return true ; } } else { Stack . Push ( ch ) ; } } return false ; } public static void Main ( String [ ] args ) { String str = " ( ( ( a + ( b ) ) + ( c + d ) ) ) " ; if ( findDuplicateparenthesis ( str ) ) { Console . WriteLine ( " Duplicate ▁ Found ▁ " ) ; } else { Console . WriteLine ( " No ▁ Duplicates ▁ Found ▁ " ) ; } } }

Accumulator variables: elementsInside
Iterator variables: ch
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; public class GFG { public static void nextGreater ( int [ ] arr , int [ ] next , char order ) { Stack < int > stack = new Stack < int > ( ) ; for ( int i = arr . Length - 1 ; i >= 0 ; i -- ) { while ( stack . Count != 0 && ( ( order == ' G ' ) ? arr [ stack . Peek ( ) ] <= arr [ i ] : arr [ stack . Peek ( ) ] >= arr [ i ] ) ) stack . Pop ( ) ; if ( stack . Count != 0 ) next [ i ] = stack . Peek ( ) ; else next [ i ] = - 1 ; stack . Push ( i ) ; } } public static void nextSmallerOfNextGreater ( int [ ] arr ) { int [ ] NG = new int [ arr . Length ] ; int [ ] RS = new int [ arr . Length ] ; nextGreater ( arr , NG , ' G ' ) ; nextGreater ( arr , RS , ' S ' ) ; for ( int i = 0 ; i < arr . Length ; i ++ ) { if ( NG [ i ] != - 1 && RS [ NG [ i ] ] != - 1 ) Console . Write ( arr [ RS [ NG [ i ] ] ] + " ▁ " ) ; else Console . Write ( " - 1 ▁ " ) ; } } public static void Main ( ) { int [ ] arr = { 5 , 1 , 9 , 2 , 5 , 1 , 7 } ; nextSmallerOfNextGreater ( arr ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class Node { public char data ; public Node left , right ; public Node ( char item ) { data = item ; left = null ; right = null ; } } public class BinaryTree { public virtual Node convertExpression ( char [ ] expression , int i ) { if ( i >= expression . Length ) { return null ; } Node root = new Node ( expression [ i ] ) ; ++ i ; if ( i < expression . Length && expression [ i ] == ' ? ' ) { root . left = convertExpression ( expression , i + 1 ) ; } else if ( i < expression . Length ) { root . right = convertExpression ( expression , i + 1 ) ; } return root ; } public virtual void printTree ( Node root ) { if ( root == null ) { return ; } Console . Write ( root . data + " ▁ " ) ; printTree ( root . left ) ; printTree ( root . right ) ; } public static void Main ( string [ ] args ) { string exp = " a ? b ? c : d : e " ; BinaryTree tree = new BinaryTree ( ) ; char [ ] expression = exp . ToCharArray ( ) ; Node root = tree . convertExpression ( expression , 0 ) ; tree . printTree ( root ) ; } }

Index/key variables: i
Class/struct names: BinaryTree, Node
C# program:
using System ; using System . Collections . Generic ; class GFG { static int countNumber ( int n ) { int result = 0 ; Stack < int > s = new Stack < int > ( ) ; for ( int i = 1 ; i <= 9 ; i ++ ) { if ( i <= n ) { s . Push ( i ) ; result ++ ; } while ( s . Count != 0 ) { int tp = s . Peek ( ) ; s . Pop ( ) ; for ( int j = tp % 10 ; j <= 9 ; j ++ ) { int x = tp * 10 + j ; if ( x <= n ) { s . Push ( x ) ; result ++ ; } } } } return result ; } public static void Main ( String [ ] args ) { int n = 15 ; Console . WriteLine ( countNumber ( n ) ) ; } }

Accumulator variables: i, j, result
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { public static int removeConsecutiveSame ( List < string > v ) { int n = v . Count ; for ( int i = 0 ; i < n - 1 ; ) { if ( v [ i ] . Equals ( v [ i + 1 ] ) ) { v . RemoveAt ( i ) ; v . RemoveAt ( i ) ; if ( i > 0 ) { i -- ; } n = n - 2 ; } else { i ++ ; } } return v . Count ; } public static void Main ( string [ ] args ) { List < string > v = new List < string > ( ) ; v . Add ( " tom " ) ; v . Add ( " jerry " ) ; v . Add ( " jerry " ) ; v . Add ( " tom " ) ; Console . WriteLine ( removeConsecutiveSame ( v ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { public static int removeConsecutiveSame ( List < string > v ) { Stack < string > st = new Stack < string > ( ) ; for ( int i = 0 ; i < v . Count ; i ++ ) { if ( st . Count == 0 ) { st . Push ( v [ i ] ) ; } else { string str = st . Peek ( ) ; if ( str . Equals ( v [ i ] ) ) { st . Pop ( ) ; } else { st . Push ( v [ i ] ) ; } } } return st . Count ; } public static void Main ( string [ ] args ) { List < string > v = new List < string > ( ) ; v . Add ( " ab " ) ; v . Add ( " aa " ) ; v . Add ( " aa " ) ; v . Add ( " bcd " ) ; v . Add ( " ab " ) ; Console . WriteLine ( removeConsecutiveSame ( v ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { public static string decode ( string str ) { Stack < int > integerstack = new Stack < int > ( ) ; Stack < char > stringstack = new Stack < char > ( ) ; string temp = " " , result = " " ; for ( int i = 0 ; i < str . Length ; i ++ ) { int count = 0 ; if ( char . IsDigit ( str [ i ] ) ) { while ( char . IsDigit ( str [ i ] ) ) { count = count * 10 + str [ i ] - '0' ; i ++ ; } i -- ; integerstack . Push ( count ) ; } else if ( str [ i ] == ' ] ' ) { temp = " " ; count = 0 ; if ( integerstack . Count > 0 ) { count = integerstack . Peek ( ) ; integerstack . Pop ( ) ; } while ( stringstack . Count > 0 && stringstack . Peek ( ) != ' [ ' ) { temp = stringstack . Peek ( ) + temp ; stringstack . Pop ( ) ; } if ( stringstack . Count > 0 && stringstack . Peek ( ) == ' [ ' ) { stringstack . Pop ( ) ; } for ( int j = 0 ; j < count ; j ++ ) { result = result + temp ; } for ( int j = 0 ; j < result . Length ; j ++ ) { stringstack . Push ( result [ j ] ) ; } result = " " ; } else if ( str [ i ] == ' [ ' ) { if ( char . IsDigit ( str [ i - 1 ] ) ) { stringstack . Push ( str [ i ] ) ; } else { stringstack . Push ( str [ i ] ) ; integerstack . Push ( 1 ) ; } } else { stringstack . Push ( str [ i ] ) ; } } while ( stringstack . Count > 0 ) { result = stringstack . Peek ( ) + result ; stringstack . Pop ( ) ; } return result ; } public static void Main ( string [ ] args ) { string str = "3 [ b2 [ ca ] ] " ; Console . WriteLine ( decode ( str ) ) ; } }

Index/key variables: ca, i, j
Accumulator variables: 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 node = new Node ( ) ; node . data = data ; node . left = null ; node . right = null ; return node ; } static void printAncestors ( Node root , int key ) { if ( root == null ) return ; Stack < Node > st = new Stack < Node > ( ) ; while ( 1 == 1 ) { while ( root != null && root . data != key ) { st . Push ( root ) ; root = root . left ; } if ( root != null && root . data == key ) break ; if ( st . Peek ( ) . right == null ) { root = st . Peek ( ) ; st . Pop ( ) ; while ( st . Count != 0 && st . Peek ( ) . right == root ) { root = st . Peek ( ) ; st . Pop ( ) ; } } root = st . Count == 0 ? null : st . Peek ( ) . right ; } while ( st . Count != 0 ) { Console . Write ( st . Peek ( ) . data + " ▁ " ) ; st . Pop ( ) ; } } public static void Main ( String [ ] args ) { Node root = newNode ( 1 ) ; root . left = newNode ( 2 ) ; root . right = newNode ( 7 ) ; root . left . left = newNode ( 3 ) ; root . left . right = newNode ( 5 ) ; root . right . left = newNode ( 8 ) ; root . right . right = newNode ( 9 ) ; root . left . left . left = newNode ( 4 ) ; root . left . right . right = newNode ( 6 ) ; root . right . right . left = newNode ( 10 ) ; int key = 6 ; printAncestors ( root , key ) ; } }

Class/struct names: GfG, Node
C# program:
using System ; using System . Collections . Generic ; class GfG { public class StackWithMax { static Stack < int > mainStack = new Stack < int > ( ) ; static Stack < int > trackStack = new Stack < int > ( ) ; public void push ( int x ) { mainStack . Push ( x ) ; if ( mainStack . Count == 1 ) { trackStack . Push ( x ) ; return ; } if ( x > trackStack . Peek ( ) ) trackStack . Push ( x ) ; else trackStack . Push ( trackStack . Peek ( ) ) ; } public int getMax ( ) { return trackStack . Peek ( ) ; } public void pop ( ) { mainStack . Pop ( ) ; trackStack . Pop ( ) ; } } ; public static void Main ( ) { StackWithMax s = new StackWithMax ( ) ; s . push ( 20 ) ; Console . WriteLine ( s . getMax ( ) ) ; s . push ( 10 ) ; Console . WriteLine ( s . getMax ( ) ) ; s . push ( 50 ) ; Console . WriteLine ( s . getMax ( ) ) ; } }

Class/struct names: GfG, StackWithMax
C# program:
using System ; using System . Collections . Generic ; class GFG { public static Stack < int > st = new Stack < int > ( ) ; public static void push_digits ( int number ) { while ( number != 0 ) { st . Push ( number % 10 ) ; number = number / 10 ; } } public static int reverse_number ( int number ) { push_digits ( number ) ; int reverse = 0 ; int i = 1 ; while ( st . Count > 0 ) { reverse = reverse + ( st . Peek ( ) * i ) ; st . Pop ( ) ; i = i * 10 ; } return reverse ; } public static void Main ( string [ ] args ) { int number = 39997 ; Console . WriteLine ( reverse_number ( number ) ) ; } }

Class/struct names: GFG