dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; class GFG { static int n ; static int solve ( int i , int X , int Y , int [ ] a , int [ ] b , int n ) { if ( i == n ) return 0 ; if ( X <= 0 ) return b [ i ] + solve ( i + 1 , X , Y - 1 , a , b , n ) ; if ( Y <= 0 ) return a [ i ] + solve ( i + 1 , X - 1 , Y , a , b , n ) ; else return Math . Max ( a [ i ] + solve ( i + 1 , X - 1 , Y , a , b , n ) , b [ i ] + solve ( i + 1 , X , Y - 1 , a , b , n ) ) ; } public static void Main ( String [ ] args ) { int [ ] a = { 1 , 2 , 3 , 4 , 5 } ; int [ ] b = { 5 , 4 , 3 , 2 , 1 } ; int x = 3 , y = 3 ; Console . Write ( solve ( 0 , x , y , a , b , n ) ) ; } }

Index/key variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static int evenNumSubstring ( string str ) { int len = str . Length ; int count = 0 ; for ( int i = 0 ; i < len ; i ++ ) { int temp = str [ i ] - '0' ; if ( temp % 2 == 0 ) count += ( i + 1 ) ; } return count ; } public static void Main ( ) { string str = "1234" ; Console . Write ( evenNumSubstring ( str ) ) ; } }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GfG { class Node { public Node left , right ; public int val ; } static Node newNode ( int val ) { Node temp = new Node ( ) ; temp . val = val ; temp . left = null ; temp . right = null ; return temp ; } static int maxPathLenUtil ( Node root , int prev_val , int prev_len ) { if ( root == null ) return prev_len ; int cur_val = root . val ; if ( cur_val == prev_val + 1 ) { return Math . Max ( maxPathLenUtil ( root . left , cur_val , prev_len + 1 ) , maxPathLenUtil ( root . right , cur_val , prev_len + 1 ) ) ; } int newPathLen = Math . Max ( maxPathLenUtil ( root . left , cur_val , 1 ) , maxPathLenUtil ( root . right , cur_val , 1 ) ) ; return Math . Max ( prev_len , newPathLen ) ; } static int maxConsecutivePathLength ( Node root ) { if ( root == null ) return 0 ; return maxPathLenUtil ( root , root . val - 1 , 0 ) ; } public static void Main ( String [ ] args ) { Node root = newNode ( 10 ) ; root . left = newNode ( 11 ) ; root . right = newNode ( 9 ) ; root . left . left = newNode ( 13 ) ; root . left . right = newNode ( 12 ) ; root . right . left = newNode ( 13 ) ; root . right . right = newNode ( 8 ) ; Console . WriteLine ( " Maximum ▁ Consecutive " + " ▁ Increasing ▁ Path ▁ Length ▁ is ▁ " + maxConsecutivePathLength ( root ) ) ; } }

Class/struct names: GfG, Node
C# program:
using System ; using System . Collections . Generic ; class GFG { static bool isSubSequence ( String str1 , String str2 ) { int m = str1 . Length , n = str2 . Length ; for ( int i = 0 ; i < n && j < m ; i ++ ) { if ( str1 [ j ] == str2 [ i ] ) { j ++ ; } } return ( j == m ) ; } static String findLongestString ( List < String > dict , String str ) { String result = " " ; int length = 0 ; foreach ( String word in dict ) { if ( length < word . Length && isSubSequence ( word , str ) ) { result = word ; length = word . Length ; } } return result ; } public static void Main ( String [ ] args ) { String [ ] arr = { " ale " , " apple " , " monkey " , " plea " } ; List < String > dict = new List < String > ( arr ) ; String str = " abpcplea " ; Console . WriteLine ( findLongestString ( dict , str ) ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, word
Class/struct names: GFG
C# program:
using System ; public class Suffix { public class SuffixTrieNode { static readonly int MAX_CHAR = 26 ; public SuffixTrieNode [ ] children = new SuffixTrieNode [ MAX_CHAR ] ; { for ( int i = 0 ; < ; ++ ) children [ i ] = null ; } public void insertSuffix ( String s ) { if ( s . Length > 0 ) { char cIndex = ( char ) ( s [ 0 ] - ' a ' ) ; if ( children [ cIndex ] == null ) children [ cIndex ] = new SuffixTrieNode ( ) ; children [ cIndex ] . insertSuffix ( s . Substring ( 1 ) ) ; } } } public class Suffix_trie { static readonly int MAX_CHAR = 26 ; public SuffixTrieNode root ; public Suffix_trie ( String s ) { root = new SuffixTrieNode ( ) ; for ( int i = 0 ; i < s . Length ; i ++ ) root . insertSuffix ( s . Substring ( i ) ) ; } public int _countNodesInTrie ( SuffixTrieNode node ) { if ( node == null ) return 0 ; int count = 0 ; for ( int i = 0 ; i < MAX_CHAR ; i ++ ) { if ( node . children [ i ] != null ) count += _countNodesInTrie ( node . children [ i ] ) ; } return ( 1 + count ) ; } public int countNodesInTrie ( ) { return _countNodesInTrie ( root ) ; } } static int ( ) { = new Suffix_trie ( str ) ; return sTrie . countNodesInTrie ( ) ; } public static void Main ( String [ ] args ) { String str = " ababa " ; Console . WriteLine ( " Count ▁ of ▁ distinct ▁ substrings ▁ is ▁ " + countDistinctSubstring ( str ) ) ; } }

Index/key variables: MAX_CHAR, cIndex, i
Accumulator variables: count, i
Iterator variables: i
Class/struct names: Suffix, SuffixTrieNode, Suffix_trie
C# program:
using System ; public class XOREncryption { static String encryptDecrypt ( String inputString ) { char xorKey = ' P ' ; String outputString = " " ; int len = inputString . Length ; for ( int i = 0 ; i < len ; i ++ ) { outputString = outputString + char . ToString ( ( char ) ( inputString [ i ] ^ xorKey ) ) ; } Console . WriteLine ( outputString ) ; return outputString ; } public static void Main ( String [ ] args ) { String sampleString = " GeeksforGeeks " ; Console . WriteLine ( " Encrypted ▁ String " ) ; String encryptedString = encryptDecrypt ( sampleString ) ; Console . WriteLine ( " Decrypted ▁ String " ) ; encryptDecrypt ( encryptedString ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: XOREncryption
C# program:
using System ; class GFG { static int versionCompare ( string v1 , string v2 ) { int vnum1 = 0 , vnum2 = 0 ; for ( int i = 0 , j = 0 ; ( i < v1 . Length < v2 . Length ) ; ) { while ( i < v1 . Length && v1 [ i ] != ' . ' ) { vnum1 = vnum1 * 10 + ( v1 [ i ] - '0' ) ; i ++ ; } while ( j < v2 . Length && v2 [ j ] != ' . ' ) { vnum2 = vnum2 * 10 + ( v2 [ j ] - '0' ) ; j ++ ; } if ( vnum1 > vnum2 ) return 1 ; if ( vnum2 > vnum1 ) return - 1 ; vnum1 = vnum2 = 0 ; i ++ ; j ++ ; } return 0 ; } static void Main ( ) { string version1 = "1.0.3" ; string version2 = "1.0.7" ; if ( versionCompare ( version1 , version2 ) < 0 ) Console . WriteLine ( version1 + " ▁ is ▁ smaller " ) ; else if ( versionCompare ( version1 , version2 ) > 0 ) Console . WriteLine ( version2 + " ▁ is ▁ smaller " ) ; else Console . WriteLine ( " Both ▁ version ▁ are ▁ equal " ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int MAX_CHAR = 256 ; public static Boolean isPalindrome ( String str , int l , int h ) { while ( h > l ) if ( str [ l ++ ] != str [ h -- ] ) return false ; return true ; } public static Boolean check ( String str ) { int n = str . Length ; int [ ] freq = new int [ MAX_CHAR ] ; for ( int i = 0 ; i < n ; i ++ ) { freq [ str [ i ] ] ++ ; if ( freq [ str [ i ] ] > 2 ) return true ; } int k = 0 ; for ( int i = 0 ; i < n ; i ++ ) if ( freq [ str [ i ] ] > 1 ) str . Replace ( str [ k ++ ] , str [ i ] ) ; str . Replace ( str [ k ] , ' \0' ) ; if ( isPalindrome ( str , 0 , k - 1 ) ) { if ( ( k & 1 ) == 1 ) { if ( k / 2 >= 1 ) return ( str [ k / 2 ] == str [ k / 2 - 1 ] ) ; } return false ; } return true ; } public static void Main ( String [ ] args ) { String str = " ABCABD " ; if ( check ( str ) ) Console . WriteLine ( " Repeated ▁ Subsequence ▁ Exists " ) ; else Console . WriteLine ( " Repeated ▁ Subsequence " + " ▁ Doesn ' t ▁ Exists " ) ; } }

Index/key variables: MAX_CHAR, i, k
Accumulator variables: h, i, k, l
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static Boolean prevPermutation ( char [ ] str ) { int n = str . Length - 1 ; int i = n ; while ( i > 0 && str [ i - 1 ] <= str [ i ] ) { i -- ; } if ( i <= 0 ) { return false ; } int j = i - 1 ; while ( j + 1 <= n && str [ j + 1 ] <= str [ i - 1 ] ) { j ++ ; } swap ( str , i - 1 , j ) ; String sb = String . Join ( " " , str ) ; sb = reverse ( sb ) ; str = sb . ToString ( ) . ToCharArray ( ) ; return true ; } static String swap ( char [ ] ch , int i , int j ) { char temp = ch [ i ] ; ch [ i ] = ch [ j ] ; ch [ j ] = temp ; return String . Join ( " " , ch ) ; } static String reverse ( String input ) { char [ ] temparray = input . ToCharArray ( ) ; int left , right = 0 ; right = temparray . Length - 1 ; for ( left = 0 ; left < right ; left ++ , right -- ) { char temp = temparray [ left ] ; temparray [ left ] = temparray [ right ] ; temparray [ right ] = temp ; } return String . Join ( " " , temparray ) ; } public static void Main ( String [ ] args ) { char [ ] str = "4321" . ToCharArray ( ) ; if ( prevPermutation ( str ) ) { Console . WriteLine ( " Previous ▁ permutation ▁ is ▁ " + String . Join ( " " , str ) ) ; } else { Console . WriteLine ( " Previous ▁ permutation " + " doesn ' t ▁ exist " ) ; } } }

Index/key variables: i, j, left, right
Accumulator variables: i, j, left, right
Iterator variables: left
Class/struct names: GFG
C# program:
using System ; class GFG { static int ans ; public class Node { public int val ; public Node left , right ; } ; static int length ( Node node ) { if ( node == null ) return 0 ; int left = length ( node . left ) ; int right = length ( node . right ) ; int Leftmax = 0 , Rightmax = 0 ; if ( node . left != null && node . left . val == node . val ) Leftmax += left + 1 ; if ( node . right != null && node . right . val == node . val ) Rightmax += right + 1 ; ans = Math . Max ( ans , Leftmax + Rightmax ) ; return Math . Max ( Leftmax , Rightmax ) ; } static int longestSameValuePath ( Node root ) { ans = 0 ; length ( root ) ; return ans ; } static Node newNode ( int data ) { Node temp = new Node ( ) ; temp . val = data ; temp . left = temp . right = null ; return temp ; } public static void Main ( String [ ] args ) { Node root = null ; root = newNode ( 4 ) ; root . left = newNode ( 4 ) ; root . right = newNode ( 4 ) ; root . left . left = newNode ( 4 ) ; root . left . right = newNode ( 9 ) ; root . right . right = newNode ( 5 ) ; Console . Write ( longestSameValuePath ( root ) ) ; } }

Accumulator variables: Leftmax, Rightmax
Class/struct names: GFG, Node
C# program:
using System ; class GFG { static bool isEditDistanceOne ( String s1 , String s2 ) { int m = s1 . Length , n = s2 . Length ; if ( Math . Abs ( m - n ) > 1 ) return false ; int count = 0 ; int i = 0 , j = 0 ; while ( i < m && j < n ) { if ( s1 [ i ] != s2 [ j ] ) { if ( count == 1 ) return false ; if ( m > n ) i ++ ; else if ( m < n ) j ++ ; else { i ++ ; j ++ ; } count ++ ; } else { i ++ ; j ++ ; } } if ( i < m < n ) count ++ ; return count == 1 ; } public static void Main ( ) { String s1 = " gfg " ; String s2 = " gf " ; if ( isEditDistanceOne ( s1 , s2 ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }

Index/key variables: i, j
Accumulator variables: count, i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static readonly int M = 1000 ; static int cntNum ( String X , int i , int sum , int tight , int [ , , ] dp ) { if ( i >= X . Length sum < 0 ) { if ( sum == 0 ) { return 1 ; } return 0 ; } if ( dp [ sum , i , tight ] != - 1 ) { return dp [ sum , i , tight ] ; } int res = 0 ; int end = tight != 0 ? X [ i ] - '0' : 9 ; for ( int j = 0 ; j <= end ; j ++ ) { res += cntNum ( X , i + 1 , sum - j , ( tight > 0 & ( j == end ) ) == true ? 1 : 0 , dp ) ; } return dp [ sum ] [ i ] [ tight ] = res ; } static int UtilCntNumRange ( int L , int R , int Y ) { if ( R == 0 && Y == 0 ) { return 1 ; } String str = String . Join ( " " , R ) ; int [ , , ] dp = new int [ M , M , 2 ] ; for ( int i = 0 ; i < M ; i ++ ) { for ( int j = 0 ; j < M ; j ++ ) { for ( int k = 0 ; k < 2 ; k ++ ) dp [ i , j , k ] = - 1 ; } } int cntR = cntNum ( str , 0 , Y , 1 , dp ) ; str = String . Join ( " " , L - 1 ) ; for ( int i = 0 ; i < M ; i ++ ) { for ( int j = 0 ; j < M ; j ++ ) { for ( int k = 0 ; k < 2 ; k ++ ) dp [ i , j , k ] = - 1 ; } } int cntL = cntNum ( str , 0 , Y , 1 , dp ) ; return ( cntR - cntL ) ; } public static void Main ( String [ ] args ) { int L = 20 , R = 10000 , Y = 14 ; Console . Write ( UtilCntNumRange ( L , R , Y ) ) ; } }

Index/key variables: i, sum, tight
Accumulator variables: i, j, k, res
Iterator variables: i, j, k
Class/struct names: GFG
C# program:
using System ; class GFG { static String removeSpace ( String str ) { str = str . Replace ( " ▁ " , " " ) ; return str ; } public static void Main ( ) { String str = " g ▁ eeks ▁ for ▁ ge ▁ eeks ▁ " ; Console . WriteLine ( removeSpace ( str ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { public virtual int countSubStr ( char [ ] str , int n ) { int res = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( str [ i ] == '1' ) { for ( int j = i + 1 ; j < n ; j ++ ) { if ( str [ j ] == '1' ) { res ++ ; } } } } return res ; } public static void Main ( string [ ] args ) { GFG count = new GFG ( ) ; string s = "00100101" ; char [ ] str = s . ToCharArray ( ) ; int n = str . Length ; Console . WriteLine ( count . countSubStr ( str , n ) ) ; } }

Index/key variables: i, j
Accumulator variables: i, j, res
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static char [ ] str ; static void reverse ( int low , int high ) { while ( low < high ) { char t = str [ low ] ; str [ low ] = str [ high ] ; str [ high ] = t ; ++ low ; -- high ; } } static void cycleLeader ( int shift , int len ) { int j ; char item ; for ( int i = 1 ; i < len ; i *= 3 ) { j = i ; item = str [ j + shift ] ; do { if ( j % 2 == 1 ) j = len / 2 + j / 2 ; else j /= 2 ; char t = str [ j + shift ] ; str [ j + shift ] = item ; item = t ; } while ( j != i ) ; } } static void moveNumberToSecondHalf ( ) { int k , lenFirst ; int lenRemaining = str . Length ; int shift = 0 ; while ( lenRemaining > 0 ) { k = 0 ; while ( Math . Pow ( 3 , k ) + 1 <= lenRemaining ) k ++ ; lenFirst = ( int ) Math . Pow ( 3 , k - 1 ) + 1 ; lenRemaining -= lenFirst ; cycleLeader ( shift , lenFirst ) ; reverse ( shift / 2 , shift - 1 ) ; reverse ( shift , shift + lenFirst / 2 - 1 ) ; reverse ( shift / 2 , shift + lenFirst / 2 - 1 ) ; shift += lenFirst ; } } public static void Main ( String [ ] args ) { String st = " a1b2c3d4e5f6g7" ; str = st . ToCharArray ( ) ; moveNumberToSecondHalf ( ) ; Console . Write ( str ) ; } }

Index/key variables: high, low
Accumulator variables: i, j, k, lenRemaining, shift
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 root ; public virtual Node removeShortPathNodesUtil ( Node node , int level , int k ) { if ( node == null ) { return null ; } node . left = removeShortPathNodesUtil ( node . left , level + 1 , k ) ; node . right = removeShortPathNodesUtil ( node . right , level + 1 , k ) ; if ( node . left == null && node . right == null && level < k ) { return null ; } return node ; } public virtual Node removeShortPathNodes ( Node node , int k ) { int pathLen = 0 ; return removeShortPathNodesUtil ( node , 1 , k ) ; } public virtual void printInorder ( Node node ) { if ( node != null ) { printInorder ( node . left ) ; Console . Write ( node . data + " ▁ " ) ; printInorder ( node . right ) ; } } public static void Main ( string [ ] args ) { BinaryTree tree = new BinaryTree ( ) ; int k = 4 ; 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 . left . left . left = new Node ( 7 ) ; tree . root . right . right = new Node ( 6 ) ; tree . root . right . right . left = new Node ( 8 ) ; Console . WriteLine ( " The ▁ inorder ▁ traversal ▁ of ▁ original ▁ tree ▁ is ▁ : ▁ " ) ; tree . printInorder ( tree . root ) ; Node res = tree . removeShortPathNodes ( tree . root , k ) ; Console . WriteLine ( " " ) ; Console . WriteLine ( " The ▁ inorder ▁ traversal ▁ of ▁ modified ▁ tree ▁ is ▁ : ▁ " ) ; tree . printInorder ( res ) ; } }

Class/struct names: BinaryTree, Node
C# program:
using System ; using System . Collections . Generic ; public class GFG { static char [ ] removeDuplicate ( char [ ] str , int n ) { HashSet < char > s = new HashSet < char > ( n - 1 ) ; foreach ( char x in str ) s . Add ( x ) ; char [ ] st = new char [ s . Count ] ; int i = 0 ; foreach ( char x in s ) st [ i ++ ] = x ; return st ; } public static void Main ( String [ ] args ) { char [ ] str = " geeksforgeeks " . ToCharArray ( ) ; int n = str . Length ; Console . Write ( removeDuplicate ( str , n ) ) ; } }

Accumulator variables: i
Iterator variables: x
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int ROW ; static int COL ; class Point { public int x , y ; } ; static Point newPoint ( int x , int y ) { Point temp = new Point ( ) ; temp . x = x ; temp . y = y ; return temp ; } class Node { public Point pt ; public int dist ; } ; static Node newNode ( Point p , int dist ) { Node temp = new Node ( ) ; temp . pt = p ; temp . dist = dist ; return temp ; } static bool isValid ( int row , int col ) { return ( row >= 0 ) && ( col >= 0 ) && ( row < ROW ) && ( col < COL ) ; } static int [ ] dRow = { - 1 , 0 , 0 , 1 } ; static int [ ] dCol = { 0 , - 1 , 1 , 0 } ; static void pathMoves ( char [ , ] mat , Point src , Point dest ) { int [ , ] d = new int [ ROW , COL ] ; for ( int i = 0 ; i < ROW ; i ++ ) { for ( int j = 0 ; j < COL ; j ++ ) d [ i , j ] = - 1 ; } d [ src . x , src . y ] = 0 ; bool [ , ] visited = new bool [ ROW , COL ] ; visited [ src . x , src . y ] = true ; Queue < Node > q = new Queue < Node > ( ) ; Node s = newNode ( src , 0 ) ; q . Enqueue ( s ) ; bool ok = false ; while ( q . Count > 0 ) { Node curr = q . Peek ( ) ; q . Dequeue ( ) ; Point pt = curr . pt ; if ( pt . x == dest . x && pt . y == dest . y ) { int xx = pt . x , yy = pt . y ; int dist = curr . dist ; d [ pt . x , pt . y ] = dist ; string pathmoves = " " ; while ( xx != src . x yy != src . y ) { if ( xx > 0 && d [ xx - 1 , yy ] == dist - 1 ) { pathmoves += ' D ' ; xx -- ; } if ( xx < ROW - 1 && d [ xx + 1 , yy ] == dist - 1 ) { pathmoves += ' U ' ; xx ++ ; } if ( yy > 0 && d [ xx , yy - 1 ] == dist - 1 ) { pathmoves += ' R ' ; yy -- ; } if ( yy < COL - 1 && d [ xx , yy + 1 ] == dist - 1 ) { pathmoves += ' L ' ; yy ++ ; } dist -- ; } for ( int i = pathmoves . Length - 1 ; i >= 0 ; -- i ) Console . Write ( pathmoves [ i ] ) ; ok = true ; break ; } if ( q . Count > 0 ) { q . Peek ( ) ; q . Dequeue ( ) ; } for ( int i = 0 ; i < 4 ; i ++ ) { int row = pt . x + dRow [ i ] ; int col = pt . y + dCol [ i ] ; if ( isValid ( row , col ) && ( mat [ row , col ] == '1' mat [ row , col ] == ' s ' mat [ row , col ] == ' d ' ) && ! visited [ row , col ] ) { visited [ row , col ] = true ; Node adjCell = newNode ( newPoint ( row , col ) , curr . dist + 1 ) ; q . Enqueue ( adjCell ) ; d [ row , col ] = curr . dist + 1 ; } } } if ( ok == false ) Console . Write ( - 1 ) ; } public static void Main ( ) { char [ , ] mat = { { '0' , '1' , '0' , '1' } , { '1' , '0' , '1' , '1' } , { '0' , '1' , '1' , '1' } , { '1' , '1' , '1' , '0' } } ; ROW = mat . GetLength ( 0 ) ; COL = mat . GetLength ( 0 ) ; Point src = newPoint ( 0 , 3 ) ; Point dest = newPoint ( 3 , 0 ) ; pathMoves ( mat , src , dest ) ; } }

Index/key variables: i
Accumulator variables: dist, i, j, pathmoves, xx, yy
Iterator variables: i, j
Boolean variables: ok
Class/struct names: GFG, Node, Point
C# program:
using System ; class GFG { static bool find ( double [ ] v , int n , double dest , String s ) { if ( n == 1 ) { if ( Math . Abs ( v [ 0 ] - dest ) <= 0.0000001 ) { Console . WriteLine ( s + String . Join ( " " , ( int ) dest ) + " ▁ " ) ; return true ; } return false ; } for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { double a = v [ i ] , b = v [ j ] ; String p = s ; v [ i ] = a + b ; v [ j ] = v [ n - 1 ] ; s = ( s + String . Join ( " " , ( int ) a ) + ' + ' + String . Join ( " " , ( int ) b ) + " ▁ = > ▁ " ) ; if ( find ( v , n - 1 , dest , s ) ) return true ; s = p ; v [ i ] = a - b ; v [ j ] = v [ n - 1 ] ; s = ( s + String . Join ( " " , ( int ) a ) + ' - ' + String . Join ( " " , ( int ) b ) + " ▁ = > ▁ " ) ; if ( find ( v , n - 1 , dest , s ) ) return true ; s = p ; v [ i ] = b - a ; v [ j ] = v [ n - 1 ] ; s = ( s + String . Join ( " " , ( int ) b ) + ' - ' + String . Join ( " " , ( int ) a ) + " ▁ = > ▁ " ) ; if ( find ( v , n - 1 , dest , s ) ) return true ; s = p ; v [ i ] = a * b ; v [ j ] = v [ n - 1 ] ; s = ( s + String . Join ( " " , ( int ) a ) + ' * ' + String . Join ( " " , ( int ) b ) + " ▁ = > ▁ " ) ; if ( find ( v , n - 1 , dest , s ) ) return true ; s = p ; if ( b != 0 ) { v [ i ] = a / b ; v [ j ] = v [ n - 1 ] ; s = ( s + String . Join ( " " , ( int ) a ) + ' / ' + String . Join ( " " , ( int ) b ) + " ▁ = > ▁ " ) ; if ( find ( v , n - 1 , dest , s ) ) return true ; } s = p ; if ( a != 0 ) { v [ i ] = b / a ; v [ j ] = v [ n - 1 ] ; s = ( s + String . Join ( " " , ( int ) b ) + ' / ' + String . Join ( " " , ( int ) a ) + " ▁ = > ▁ " ) ; if ( find ( v , n - 1 , dest , s ) ) return true ; } s = p ; v [ i ] = a ; v [ j ] = b ; } } return false ; } static void checkPossibleOperation ( double [ ] arr , double K ) { String s = " " ; if ( ! find ( arr , arr . Length , K , s ) ) { Console . WriteLine ( " - 1" ) ; } } public static void Main ( String [ ] args ) { double [ ] arr = { 2 , 0 , 0 , 2 } ; double K = 4 ; checkPossibleOperation ( arr , K ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; public class Node { private int x , y ; private int dir ; public Node ( int i , int j ) { this . x = i ; this . y = j ; this . dir = 0 ; } public int getX ( ) { return x ; } public void setX ( int x ) { this . x = x ; } public int getY ( ) { return y ; } public void setY ( int y ) { this . y = y ; } public int getDir ( ) { return dir ; } public void setDir ( int dir ) { this . dir = dir ; } } public class RatInMaze { private static readonly int N = 4 ; private static readonly int M = 5 ; int n = N , m = M ; private static bool [ , ] visited = new bool [ N , M ] ; public static void Main ( String [ ] args ) { setVisited ( true ) ; int [ , ] maze = { { 1 , 0 , 1 , 1 , 0 } , { 1 , 1 , 1 , 0 , 1 } , { 0 , 1 , 0 , 1 , 1 } , { 1 , 1 , 1 , 1 , 1 } } ; if ( isReachable ( maze ) ) { Console . WriteLine ( " Path ▁ Found ! STRNEWLINE " ) ; } else Console . WriteLine ( " No ▁ Path ▁ Found ! STRNEWLINE " ) ; } private static void setVisited ( bool b ) { for ( int i = 0 ; i < visited . GetLength ( 0 ) ; i ++ ) { for ( int j = 0 ; j < visited . GetLength ( 0 ) ; j ++ ) { visited [ i , j ] = b ; } } } private static bool isReachable ( int [ , ] maze ) { int i = 0 , j = 0 ; int fx , fy ; fx = 2 ; fy = 3 ; Stack < Node > s = new Stack < Node > ( ) ; Node temp = new Node ( i , j ) ; s . Push ( temp ) ; while ( s . Count != 0 ) { temp = s . Peek ( ) ; int d = temp . getDir ( ) ; i = temp . getX ( ) ; j = temp . getY ( ) ; temp . setDir ( temp . getDir ( ) + 1 ) ; s . Pop ( ) ; s . Push ( temp ) ; if ( i == fx && j == fy ) { return true ; } if ( d == 0 ) { if ( i - 1 >= 0 && maze [ i - 1 , j ] == 1 && visited [ i - 1 , j ] ) { Node temp1 = new Node ( i - 1 , j ) ; visited [ i - 1 , j ] = false ; s . Push ( temp1 ) ; } } else if ( d == 1 ) { if ( j - 1 >= 0 && maze [ i , j - 1 ] == 1 && visited [ i , j - 1 ] ) { Node temp1 = new Node ( i , j - 1 ) ; visited [ i , j - 1 ] = false ; s . Push ( temp1 ) ; } } else if ( d == 2 ) { if ( i + 1 < N && maze [ i + 1 , j ] == 1 && visited [ i + 1 , j ] ) { Node temp1 = new Node ( i + 1 , j ) ; visited [ i + 1 , j ] = false ; s . Push ( temp1 ) ; } } else if ( d == 3 ) { if ( j + 1 < M && maze [ i , j + 1 ] == 1 && visited [ i , j + 1 ] ) { Node temp1 = new Node ( i , j + 1 ) ; visited [ i , j + 1 ] = false ; s . Push ( temp1 ) ; } } else { visited [ temp . getX ( ) , temp . getY ( ) ] = true ; s . Pop ( ) ; } } return false ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: Node, RatInMaze