dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; class GFG { static long polynomialRollingHash ( String str ) { int p = 31 ; int m = ( int ) ( 1e9 + 9 ) ; long power_of_p = 1 ; long hash_val = 0 ; for ( int i = 0 ; i < str . Length ; i ++ ) { hash_val = ( hash_val + ( str [ i ] - ' a ' + 1 ) * power_of_p ) % m ; power_of_p = ( power_of_p * p ) % m ; } return hash_val ; } public static void Main ( String [ ] args ) { String str1 = " geeksforgeeks " ; String str2 = " geeks " ; Console . Write ( " Hash ▁ of ▁ ' " + str1 + " ' ▁ = ▁ " + polynomialRollingHash ( str1 ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections ; using System . Collections . Generic ; class FirstNonRepeatingElement { static void firstNonRepElement ( string str ) { LinkedList < char > list = new LinkedList < char > ( ) ; list . AddLast ( str [ 0 ] ) ; for ( int i = 1 ; i < str . Length ; i ++ ) { if ( list . Contains ( str [ i ] ) ) list . Remove ( str [ i ] ) ; else list . AddLast ( str [ i ] ) ; } Console . Write ( list . First . Value ) ; } public static void Main ( string [ ] args ) { string str = " geeksforgeeks " ; firstNonRepElement ( str ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: FirstNonRepeatingElement
C# program:
using System ; using System . Collections ; using System . Collections . Generic ; class GFG { static void stateA ( string n ) { if ( n [ 0 ] == ' a ' ) { stateB ( n . Substring ( 1 ) ) ; } else { stateQ ( n ) ; } } static void stateB ( string n ) { if ( n . Length == 0 ) { Console . Write ( " Accepted " ) ; } else { if ( n [ 0 ] == ' a ' ) stateC ( n . Substring ( 1 ) ) ; else stateD ( n . Substring ( 1 ) ) ; } } static void stateC ( string n ) { if ( n . Length == 0 ) Console . Write ( " Accepted " ) ; else { if ( n [ 0 ] == ' a ' ) stateC ( n . Substring ( 1 ) ) ; else stateQ ( n ) ; } } static void stateD ( string n ) { if ( n . Length == 0 ) Console . Write ( " Accepted " ) ; else { if ( n [ 0 ] == ' a ' ) { stateB ( n . Substring ( 1 ) ) ; } else { stateD ( n . Substring ( 1 ) ) ; } } } static void stateQ ( string n ) { Console . Write ( " Not ▁ Accepted " ) ; } public static void Main ( string [ ] args ) { string n = " aaaba " ; stateA ( n ) ; } }

Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { public static int countSubstrings ( string str , int K ) { int N = str . Length ; int answer = 0 ; Dictionary < char , int > map = new Dictionary < char , int > ( ) ; for ( int i = 0 ; i < K ; i ++ ) { if ( ! map . ContainsKey ( str [ i ] ) ) { map [ str [ i ] ] = 1 ; } else { map [ str [ i ] ] ++ ; } } if ( map . Count == K ) answer ++ ; for ( int i = K ; i < N ; i ++ ) { if ( ! map . ContainsKey ( str [ i ] ) ) { map [ str [ i ] ] = 1 ; } else { map [ str [ i ] ] ++ ; } map [ str [ i - K ] ] -- ; if ( map [ str [ i - K ] ] == 0 ) { map . Remove ( str [ i - K ] ) ; } if ( map . Count == K ) { answer ++ ; } } return answer ; } public static void Main ( string [ ] args ) { string str = " aabcdabbcdc " ; int K = 3 ; Console . Write ( countSubstrings ( str , K ) ) ; } }

Index/key variables: i
Accumulator variables: answer, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static Dictionary < string , bool > mp = new Dictionary < string , bool > ( ) ; static bool isScramble ( string S1 , string S2 ) { if ( S1 . Length != S2 . Length ) { return false ; } int n = S1 . Length ; if ( n == 0 ) { return true ; } if ( S1 == S2 ) { return true ; } string copy_S1 = S1 , copy_S2 = S2 ; char [ ] t1 = copy_S1 . ToCharArray ( ) ; char [ ] t2 = copy_S2 . ToCharArray ( ) ; Array . Sort ( t1 ) ; Array . Sort ( t2 ) ; copy_S1 = new string ( t1 ) ; copy_S2 = new string ( t2 ) ; if ( copy_S1 != copy_S2 ) { return false ; } string key = ( S1 + " ▁ " + S2 ) ; if ( mp . ContainsKey ( key ) ) { return mp [ key ] ; } bool flag = false ; for ( int i = 1 ; i < n ; i ++ ) { if ( isScramble ( S1 . Substring ( 0 , i ) , S2 . Substring ( 0 , i ) ) && isScramble ( S1 . Substring ( i , n - i ) , S2 . Substring ( i , n - i ) ) ) { flag = true ; return true ; } if ( isScramble ( S1 . Substring ( 0 , i ) , S2 . Substring ( n - i , i ) ) && isScramble ( S1 . Substring ( i , n - i ) , S2 . Substring ( 0 , n - i ) ) ) { flag = true ; return true ; } } mp [ key ] = flag ; return false ; } static void Main ( ) { string S1 = " coder " ; string S2 = " ocred " ; if ( isScramble ( S1 , S2 ) ) { Console . Write ( " Yes " ) ; } else { Console . Write ( " No " ) ; } } }

Index/key variables: key
Accumulator variables: i
Iterator variables: i
Boolean variables: flag
Class/struct names: GFG
C# program:
using System ; class GFG { static void longestPalindromicPrefix ( String s ) { int n = s . Length ; int max_len = 0 ; for ( int len = 1 ; len <= n ; len ++ ) { String temp = s . Substring ( 0 , len ) ; String temp2 = temp ; temp2 = reverse ( temp2 ) ; if ( temp . Equals ( temp2 ) ) { max_len = len ; } } Console . Write ( s . Substring ( 0 , max_len ) ) ; } static String reverse ( String input ) { char [ ] a = input . ToCharArray ( ) ; int l , r = a . Length - 1 ; for ( l = 0 ; l < r ; l ++ , r -- ) { char temp = a [ l ] ; a [ l ] = a [ r ] ; a [ r ] = temp ; } return String . Join ( " " , a ) ; } public static void Main ( String [ ] args ) { String str = " abaab " ; longestPalindromicPrefix ( str ) ; } }

Index/key variables: l, r
Accumulator variables: l, len, r
Iterator variables: l, len
Class/struct names: GFG
C# program:
using System ; class GFG { static String find_kth_String_of_n ( int n , int k ) { int [ ] d = new int [ n ] ; for ( int i = n - 1 ; i > - 1 ; i -- ) { d [ i ] = k % 26 ; k /= 26 ; } if ( k > 0 ) return " - 1" ; string s = " " ; for ( int i = 0 ; i < n ; i ++ ) s += ( char ) ( d [ i ] + ( ' a ' ) ) ; return s ; } public static void Main ( ) { int n = 3 ; int k = 10 ; k -= 1 ; Console . Write ( find_kth_String_of_n ( n , k ) ) ; } }

Index/key variables: i, n
Accumulator variables: i, k, s
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { public static int findMinLength ( String s ) { int n = s . Length ; int i = 0 ; Dictionary < char , int > counts = new Dictionary < char , int > ( ) ; List < int > indices = new List < int > ( ) ; for ( i = 0 ; i < n ; i ++ ) { if ( s [ i ] == ' a ' s [ i ] == ' e ' s [ i ] == ' o ' s [ i ] == ' i ' s [ i ] == ' u ' ) { if ( counts . ContainsKey ( s [ i ] ) ) { counts [ s [ i ] ] = counts [ s [ i ] ] + 1 ; } else { counts . Add ( s [ i ] , 1 ) ; } indices . Add ( i ) ; } } if ( counts . Count < 5 ) return - 1 ; int flag1 = 0 , flag2 = 0 ; i = 0 ; int j = indices . Count - 1 ; while ( ( j - i ) >= 4 ) { if ( flag1 == 0 && counts [ s [ indices [ i ] ] ] > 1 ) { counts [ s [ indices [ i ] ] ] = counts [ s [ indices [ i ] ] ] - 1 ; i ++ ; } else flag1 = 1 ; if ( flag2 == 0 && counts [ s [ indices [ j ] ] ] > 1 ) { counts [ s [ indices [ j ] ] ] = counts [ s [ indices [ j ] ] ] - 1 ; j -- ; } else flag2 = 1 ; if ( flag1 == 1 && flag2 == 1 ) break ; } return ( indices [ j ] - indices [ i ] + 1 ) ; } public static void Main ( String [ ] args ) { String s = " aaeebbeaccaaoiuooooooooiuu " ; Console . Write ( findMinLength ( s ) ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static bool isConsonants ( char x ) { x = Char . ToLower ( x ) ; return ! ( x == ' a ' x == ' e ' x == ' i ' x == ' o ' x == ' u ' ) ; } static string longestConsonantsSubsequence ( string str ) { string answer = " " ; int n = str . Length ; for ( int i = 0 ; i < n ; i ++ ) { if ( isConsonants ( str [ i ] ) ) { answer += str [ i ] ; } } return answer ; } static void Main ( ) { string str = " geeksforgeeks " ; Console . Write ( longestConsonantsSubsequence ( str ) + " STRNEWLINE " ) ; } }

Index/key variables: i
Accumulator variables: answer, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int lengthOfSubsequence ( string str , int K ) { Dictionary < char , int > mp = new Dictionary < char , int > ( ) ; foreach ( char ch in str . ToCharArray ( ) ) { mp [ ch ] = mp . GetValueOrDefault ( ch , 0 ) + 1 ; } int minimum = mp [ ' A ' ] ; for ( int i = 1 ; i < K ; i ++ ) { minimum = Math . Min ( minimum , mp [ ( char ) ( i + ' A ' ) ] ) ; } return minimum * K ; } public static void Main ( string [ ] args ) { string str = " ACAABCCAB " ; int K = 3 ; Console . Write ( lengthOfSubsequence ( str , K ) ) ; } }

Index/key variables: ch
Accumulator variables: i
Iterator variables: ch, i
Class/struct names: GFG
C# program:
using System ; namespace Cycle { public class GFG { static int V = 4 ; static int INF = 99999 ; static bool negCyclefloydWarshall ( int [ , ] graph ) { int [ , ] dist = new int [ V , V ] ; int i , j , k ; for ( i = 0 ; i < V ; i ++ ) for ( j = 0 ; j < V ; j ++ ) dist [ i , j ] = graph [ i , j ] ; for ( k = 0 ; k < V ; k ++ ) { for ( i = 0 ; i < V ; i ++ ) { for ( j = 0 ; j < V ; j ++ ) { if ( dist [ i , k ] + dist [ k , j ] < dist [ i , j ] ) dist [ i , j ] = dist [ i , k ] + dist [ k , j ] ; } } } for ( i = 0 ; i < V ; i ++ ) if ( dist [ i , i ] < 0 ) return true ; return false ; } public static void Main ( ) { int [ , ] graph = { { 0 , 1 , INF , INF } , { INF , 0 , - 1 , INF } , { INF , INF , 0 , - 1 } , { - 1 , INF , INF , 0 } } ; if ( negCyclefloydWarshall ( graph ) ) Console . Write ( " Yes " ) ; else Console . Write ( " No " ) ; } } }

Accumulator variables: i, j, k
Iterator variables: i, j, k
Class/struct names: GFG
C# program:
using System ; class GFG { static String convertToString ( int sum ) { String str = " " ; while ( sum > 0 ) { str = str + ( char ) ( ( sum % 10 ) + '0' ) ; sum = sum / 10 ; } return str ; } static String GetIndividulaDigitSum ( String str , int len ) { int sum = 0 ; for ( int i = 0 ; i < len ; i ++ ) { sum = sum + str [ i ] - '0' ; } return convertToString ( sum ) ; } static int GetDigitalRoot ( String str ) { if ( str . Length == 1 ) { return str [ 0 ] - '0' ; } str = GetIndividulaDigitSum ( str , str . Length ) ; return GetDigitalRoot ( str ) ; } public static void Main ( String [ ] args ) { String str = "675987890789756545689070986776987" ; Console . Write ( GetDigitalRoot ( str ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void count ( string str1 , string str2 ) { int c = 0 , j = 0 ; for ( int i = 0 ; i < str1 . Length ; i ++ ) { if ( str2 . IndexOf ( str1 [ i ] ) >= 0 ) { c += 1 ; } } Console . WriteLine ( " No . ▁ of ▁ matching ▁ characters ▁ are : ▁ " + c ) ; } public static void Main ( ) { string str1 = " aabcddekll12 @ " ; string str2 = " bb2211@55k " ; count ( str1 , str2 ) ; } }

Index/key variables: i
Accumulator variables: c, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int countOfLetters ( String str ) { int letter = 0 ; for ( int i = 0 ; i < str . Length ; i ++ ) { if ( ( str [ i ] >= ' A ' && str [ i ] <= ' Z ' ) || ( str [ i ] >= ' a ' && str [ i ] <= ' z ' ) ) letter ++ ; } return letter ; } static int countOfNumbers ( String str ) { int number = 0 ; for ( int i = 0 ; i < str . Length ; i ++ ) { if ( str [ i ] >= '0' && str [ i ] <= '9' ) number ++ ; } return number ; } static void check ( String str ) { if ( countOfLetters ( str ) == countOfNumbers ( str ) ) Console . Write ( " Yes STRNEWLINE " ) ; else Console . Write ( " No STRNEWLINE " ) ; } public static void Main ( String [ ] args ) { String str = " GeeKs01324" ; check ( str ) ; } }

Index/key variables: i
Accumulator variables: i, letter, number
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int findMinCost ( char [ ] s , int i , int j ) { List < int > [ ] gr = new List < int > [ 26 ] ; for ( int iN = 0 ; iN < 26 ; iN ++ ) gr [ iN ] = new List < int > ( ) ; bool [ , ] edge = new bool [ 26 , 26 ] ; for ( int k = 0 ; k < 26 ; k ++ ) for ( int l = 0 ; l < 26 ; l ++ ) edge [ k , l ] = false ; for ( int k = 0 ; k < s . Length ; k ++ ) { if ( k - 1 >= 0 && ! edge [ s [ k ] - 97 , s [ k - 1 ] - 97 ] ) { gr [ s [ k ] - 97 ] . Add ( s [ k - 1 ] - 97 ) ; edge [ s [ k ] - 97 , s [ k - 1 ] - 97 ] = true ; } if ( k + 1 <= s . Length - 1 && ! edge [ s [ k ] - 97 , s [ k + 1 ] - 97 ] ) { gr [ s [ k ] - 97 ] . Add ( s [ k + 1 ] - 97 ) ; edge [ s [ k ] - 97 , s [ k + 1 ] - 97 ] = true ; } } Queue < int > q = new Queue < int > ( ) ; q . Enqueue ( s [ i ] - 97 ) ; bool [ ] v = new bool [ 26 ] ; int d = 0 ; while ( q . Count > 0 ) { int cnt = q . Count ; while ( cnt -- > 0 ) { int curr = q . Peek ( ) ; q . Dequeue ( ) ; if ( v [ curr ] ) continue ; v [ curr ] = true ; if ( curr == s [ j ] - 97 ) return d ; foreach ( int it in gr [ curr ] ) q . Enqueue ( it ) ; } d ++ ; } return - 1 ; } public static void Main ( String [ ] args ) { String s = " abcde " ; int i = 0 ; int j = 4 ; Console . Write ( findMinCost ( s . ToCharArray ( ) , i , j ) ) ; } }

Index/key variables: curr, i, iN, j, k
Accumulator variables: cnt, d, iN, k, l
Iterator variables: iN, it, k, l
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static bool twoColorUtil ( List < int > [ ] G , int src , int N , int [ ] colorArr ) { colorArr [ src ] = 1 ; List < int > q = new List < int > ( ) ; q . Add ( src ) ; while ( q . Count != 0 ) { int u = q [ 0 ] ; q . RemoveAt ( 0 ) ; for ( int v = 0 ; v < G [ u ] . Count ; ++ v ) { if ( colorArr [ G [ u ] [ v ] ] == - 1 ) { colorArr [ G [ u ] [ v ] ] = 1 - colorArr [ u ] ; q . Add ( G [ u ] [ v ] ) ; } else if ( colorArr [ G [ u ] [ v ] ] == colorArr [ u ] ) return false ; } } return true ; } static bool twoColor ( List < int > [ ] G , int N ) { int [ ] colorArr = new int [ N + 1 ] ; for ( int i = 1 ; i <= N ; ++ i ) colorArr [ i ] = - 1 ; for ( int i = 1 ; i <= N ; i ++ ) if ( colorArr [ i ] == - 1 ) if ( twoColorUtil ( G , i , N , colorArr ) == false ) return false ; return true ; } static bool isOddSum ( int [ , ] info , int n , int m ) { List < int > [ ] G = new List < int > [ 2 * n ] ; for ( int i = 0 ; i < 2 * n ; i ++ ) G [ i ] = new List < int > ( ) ; int pseudo = n + 1 ; int pseudo_count = 0 ; for ( int i = 0 ; i < m ; i ++ ) { if ( info [ i , 2 ] % 2 == 1 ) { int u = info [ i , 0 ] ; int v = info [ i , 1 ] ; G [ u ] . Add ( v ) ; G [ v ] . Add ( u ) ; } else { int u = info [ i , 0 ] ; int v = info [ i , 1 ] ; G [ u ] . Add ( pseudo ) ; G [ pseudo ] . Add ( u ) ; G [ v ] . Add ( pseudo ) ; G [ pseudo ] . Add ( v ) ; pseudo_count ++ ; pseudo ++ ; } } return twoColor ( G , n + pseudo_count ) ; } public static void Main ( String [ ] args ) { int n = 4 , m = 3 ; int [ , ] info = { { 1 , 2 , 12 } , { 2 , 3 , 1 } , { 4 , 3 , 1 } , { 4 , 1 , 20 } } ; if ( isOddSum ( info , n , m ) == true ) Console . WriteLine ( " No " ) ; else Console . WriteLine ( " Yes " ) ; } }

Index/key variables: i, pseudo, src, u, v
Accumulator variables: i, pseudo, pseudo_count
Iterator variables: i, v
Class/struct names: GFG
C# program:
using System ; class GFG { static int MAX = 26 ; static void performQueries ( String str , int q , int [ ] type , char [ ] ch , int [ ] freq ) { int n = str . Length ; int [ , ] L = new int [ MAX , n ] ; int [ , ] F = new int [ MAX , n ] ; int [ ] cnt = new int [ MAX ] ; for ( int i = 0 ; i < n ; i ++ ) { int k = str [ i ] - ' a ' ; cnt [ k ] ++ ; for ( int j = 0 ; j < MAX ; j ++ ) { if ( k == j ) { L [ j , cnt [ j ] ] = i ; F [ j , cnt [ j ] ] = i ; } else L [ j , cnt [ j ] ] = L [ j , cnt [ j ] ] + 1 ; } } for ( int i = 0 ; i < q ; i ++ ) { if ( type [ i ] == 1 ) { Console . Write ( L [ ch [ i ] - ' a ' , freq [ i ] ] ) ; } else { Console . Write ( F [ ch [ i ] - ' a ' , freq [ i ] ] ) ; } Console . Write ( " STRNEWLINE " ) ; } } public static void Main ( String [ ] args ) { String str = " geeksforgeeks " ; int [ ] type = { 1 , 2 } ; char [ ] ch = { ' e ' , ' k ' } ; int [ ] freq = { 2 , 2 } ; int q = type . Length ; performQueries ( str , q , type , ch , freq ) ; } }

Index/key variables: MAX, i, j, k
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int anagram_pairs ( String [ ] s , int n ) { Dictionary < String , int > mp = new Dictionary < String , int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { char [ ] chArr = s [ i ] . ToCharArray ( ) ; Array . Sort ( chArr ) ; s [ i ] = new String ( chArr ) ; if ( mp . ContainsKey ( s [ i ] ) ) { mp [ s [ i ] ] = mp [ s [ i ] ] + 1 ; } else { mp . Add ( s [ i ] , 1 ) ; } } int ans = 0 ; foreach ( KeyValuePair < String , int > i in mp ) { int k = i . Value ; ans += ( k * ( k - 1 ) ) / 2 ; } return ans ; } public static void Main ( String [ ] args ) { String [ ] s = { " aaab " , " aaba " , " baaa " , " cde " , " dec " } ; int n = s . Length ; Console . WriteLine ( anagram_pairs ( s , n ) ) ; } }

Index/key variables: i
Accumulator variables: ans, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static char Insert ( char [ ] arr , int n , int k ) { int ind = 0 ; int sz = 0 ; String s = " " ; char ch = arr [ 0 ] ; s += ch ; sz = 1 ; ind = 0 ; for ( int i = 1 ; i < n ; i ++ ) { ch = arr [ i ] ; string s1 = s . Substring ( 0 , ind + 1 ) ; int temp = k % sz ; int ro = temp - Math . Min ( temp , sz - ind - 1 ) ; if ( ro == 0 ) { string s2 = s . Substring ( ind + 1 , temp ) ; string s3 = s . Substring ( ind + temp + 1 , sz - ind - temp - 1 ) ; s = s1 + s2 + ch + s3 ; ind = s1 . Length + s2 . Length ; sz = s . Length ; } else { string s2 = s . Substring ( 0 , ro ) ; string s3 = s . Substring ( ro , sz - ro ) ; s = s2 + ch + s3 ; ind = s2 . Length ; sz = s . Length ; } } if ( ind == 0 ) { return s [ sz - 1 ] ; } else { return s [ ind - 1 ] ; } } static public void Main ( ) { char [ ] arr = { '1' , '2' , '3' , '4' , '5' } ; int k = 2 ; int n = arr . Length ; Console . WriteLine ( Insert ( arr , n , k ) ) ; } }

Index/key variables: i
Accumulator variables: i, s
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; public class GFG { static bool isCycleRec ( int v , List < int > [ ] adj , List < Boolean > visited , List < Boolean > recur ) { visited [ v ] = true ; recur [ v ] = true ; for ( int i = 0 ; i < adj [ v ] . Count ; i ++ ) { if ( visited [ adj [ v ] [ i ] ] == false ) { if ( isCycleRec ( adj [ v ] [ i ] , adj , visited , recur ) ) return true ; } else if ( visited [ adj [ v ] [ i ] ] == true && recur [ adj [ v ] [ i ] ] == true ) return true ; } recur [ v ] = false ; return false ; } static bool isCycle ( int [ ] arr , int n ) { List < int > [ ] adj = new List < int > [ n ] ; for ( int i = 0 ; i < n ; i ++ ) if ( i != ( i + arr [ i ] + n ) % n && adj [ i ] != null ) adj [ i ] . Add ( ( i + arr [ i ] + n ) % n ) ; List < Boolean > visited = new List < Boolean > ( ) ; for ( int i = 0 ; i < n ; i ++ ) visited . Add ( true ) ; List < Boolean > recur = new List < Boolean > ( ) ; for ( int i = 0 ; i < n ; i ++ ) recur . Add ( true ) ; for ( int i = 0 ; i < n ; i ++ ) if ( visited [ i ] == false ) if ( isCycleRec ( i , adj , visited , recur ) ) return true ; return true ; } public static void Main ( String [ ] args ) { int [ ] arr = { 2 , - 1 , 1 , 2 , 2 } ; int n = arr . Length ; if ( isCycle ( arr , n ) == true ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }

Index/key variables: i, n, v
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int MAX = 256 ; static int [ , ] freq ; static void preCalculate ( string str , int n ) { freq [ ( int ) str [ 0 ] , 0 ] = 1 ; for ( int i = 1 ; i < n ; i ++ ) { char ch = str [ i ] ; for ( int j = 0 ; j < MAX ; j ++ ) { char charToUpdate = ( char ) j ; if ( charToUpdate == ch ) freq [ j , i ] = freq [ j , i - 1 ] + 1 ; else freq [ j , i ] = freq [ j , i - 1 ] ; } } } static int getFrequency ( char ch , int l , int r ) { if ( l == 0 ) return freq [ ( int ) ch , r ] ; else return ( freq [ ( int ) ch , r ] - freq [ ( int ) ch , l - 1 ] ) ; } static String lastNonRepeating ( string str , int n , int l , int r ) { for ( int i = r ; i >= l ; i -- ) { char ch = str [ i ] ; if ( getFrequency ( ch , l , r ) == 1 ) return ( " " + ch ) ; } return " - 1" ; } public static void Main ( ) { string str = " GeeksForGeeks " ; int n = str . Length ; int [ , ] queries = { { 2 , 9 } , { 2 , 3 } , { 0 , 12 } } ; int q = queries . Length ; freq = new int [ MAX , n ] ; preCalculate ( str , n ) ; for ( int i = 0 ; i < q ; i ++ ) { Console . WriteLine ( lastNonRepeating ( str , n , queries [ i , 0 ] , queries [ i , 1 ] ) ) ; } } }

Index/key variables: i
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void pre_process ( String [ ] substrings , String s ) { int n = s . Length ; int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { String dup = " " ; for ( int j = i ; j < n ; j ++ ) { dup += s [ j ] ; substrings [ count ++ ] = dup ; } } int size = substrings . Length ; for ( int i = 0 ; i < size - 1 ; i ++ ) { for ( int j = i + 1 ; j < substrings . Length ; j ++ ) { if ( substrings [ i ] . CompareTo ( substrings [ j ] ) > 0 ) { String temp = substrings [ i ] ; substrings [ i ] = substrings [ j ] ; substrings [ j ] = temp ; } } } } public static void Main ( String [ ] args ) { String s = " geek " ; String [ ] substrings = new String [ 10 ] ; pre_process ( substrings , s ) ; int [ ] queries = { 1 , 5 , 10 } ; int q = queries . Length ; for ( int i = 0 ; i < q ; i ++ ) Console . WriteLine ( substrings [ queries [ i ] - 1 ] ) ; } }

Index/key variables: i, j
Accumulator variables: count, dup, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int minCost ( String str , int K ) { int n = str . Length ; int res = 999999999 , count = 0 , a , b ; int [ ] cnt = new int [ 27 ] ; for ( int i = 0 ; i < n ; i ++ ) cnt [ str [ i ] - ' a ' + 1 ] ++ ; for ( int i = 1 ; i < ( 26 - K + 1 ) ; i ++ ) { a = i ; b = i + K ; count = 0 ; for ( int j = 1 ; j <= 26 ; j ++ ) { if ( cnt [ j ] > 0 ) { if ( j >= a && j >= b ) count = count + ( Math . Min ( j - b , 25 - j + a + 1 ) ) * cnt [ j ] ; else if ( j <= a && j <= b ) count = count + ( Math . Min ( a - j , 25 + j - b + 1 ) ) * cnt [ j ] ; } } res = Math . Min ( res , count ) ; } for ( int i = 26 - K + 1 ; i <= 26 ; i ++ ) { a = i ; b = ( i + K ) % 26 ; count = 0 ; for ( int j = 1 ; j <= 26 ; j ++ ) { if ( cnt [ j ] > 0 ) { if ( j >= b && j <= a ) count = count + ( Math . Min ( j - b , a - j ) ) * cnt [ j ] ; } } res = Math . Min ( res , count ) ; } return res ; } public static void Main ( String [ ] args ) { String str = " abcdefghi " ; int K = 2 ; Console . WriteLine ( minCost ( str , K ) ) ; } }

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