dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; class GFG { static void printBinStr ( int [ ] str , int len ) { for ( int i = 0 ; i < len ; i ++ ) { Console . Write ( str [ i ] ) ; } Console . Write ( " STRNEWLINE " ) ; } static void generateBinStr ( int [ ] str , int len , int currlen , int occur , int nextbit ) { if ( currlen == len ) { if ( occur == 2 && nextbit == 0 ) { printBinStr ( str , len ) ; } return ; } if ( currlen == 0 ) { str [ 0 ] = nextbit ; generateBinStr ( str , len , currlen + 1 , occur , 0 ) ; generateBinStr ( str , len , currlen + 1 , occur , 1 ) ; if ( occur < 2 ) { str [ currlen ] = nextbit ; if ( str [ currlen - 1 ] == 0 && nextbit == 1 ) { occur += 1 ; } generateBinStr ( str , len , currlen + 1 , occur , 0 ) ; generateBinStr ( str , len , currlen + 1 , occur , 1 ) ; if ( str [ currlen - 1 ] == 0 && nextbit == 1 ) { return ; } else { str [ currlen ] = nextbit ; generateBinStr ( str , len , currlen + 1 , occur , 0 ) ; generateBinStr ( str , len , currlen + 1 , occur , 1 ) ; } } public static void Main ( String [ ] args ) { int n = 5 ; if ( n < 4 ) { Console . Write ( - 1 ) ; } else { int [ ] str = new int [ n ] ; generateBinStr ( str , n , 0 , 0 , 0 ) ; generateBinStr ( str , n , 0 , 0 , 1 ) ; } } }

Index/key variables: currlen, i, n
Accumulator variables: i, occur
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void printLastChar ( string str ) { str = str + " ▁ " ; for ( int i = 1 ; i < str . Length ; i ++ ) { if ( str [ i ] == ' ▁ ' ) Console . Write ( str [ i - 1 ] + " ▁ " ) ; } } public static void Main ( ) { string str = " Geeks ▁ for ▁ Geeks " ; printLastChar ( str ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int maxBalancedStr ( string s ) { int open1 = 0 , close1 = 0 ; int open2 = 0 , close2 = 0 ; int open3 = 0 , close3 = 0 ; for ( int i = 0 ; i < s . Length ; i ++ ) { switch ( s [ i ] ) { case ' ( ' : open1 ++ ; break ; case ' ) ' : close1 ++ ; break ; case ' { ' : open2 ++ ; break ; case ' } ' : close2 ++ ; break ; case ' [ ' : open3 ++ ; break ; case ' ] ' : close3 ++ ; break ; } } int maxLen = 2 * Math . Min ( open1 , close1 ) + 2 * Math . Min ( open2 , close2 ) + 2 * Math . Min ( open3 , close3 ) ; return maxLen ; } public static void Main ( ) { string s = " ) ) [ ] ] ( ( " ; Console . WriteLine ( maxBalancedStr ( s ) ) ; } }

Index/key variables: i
Accumulator variables: close1, close2, close3, i, open1, open2, open3
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static String strBitwiseOR ( String [ ] arr , int n ) { String res = " " ; int max_size = int . MinValue ; for ( int i = 0 ; i < n ; i ++ ) { max_size = Math . Max ( max_size , ( int ) arr [ i ] . Length ) ; arr [ i ] = reverse ( arr [ i ] ) ; } for ( int i = 0 ; i < n ; i ++ ) { String s = " " ; for ( int j = 0 ; j < max_size - arr [ i ] . Length ; j ++ ) s += '0' ; arr [ i ] = arr [ i ] + s ; } for ( int i = 0 ; i < max_size ; i ++ ) { int curr_bit = 0 ; for ( int j = 0 ; j < n ; j ++ ) curr_bit = curr_bit | ( arr [ j ] [ i ] - '0' ) ; res += ( char ) ( curr_bit + '0' ) ; } res = reverse ( res ) ; return res ; } static String reverse ( String input ) { char [ ] temparray = input . ToCharArray ( ) ; int left , right = 0 ; right = temparray . Length - 1 ; for ( left = 0 ; left < right ; left ++ , right -- ) { public static void Main ( String [ ] args ) { String [ ] arr = { "10" , "11" , "1000001" } ; int n = arr . Length ; Console . WriteLine ( strBitwiseOR ( arr , n ) ) ; } }

Index/key variables: i, j
Accumulator variables: i, j, left, res, right, s
Iterator variables: i, j, left
Class/struct names: GFG
C# program:
using System ; class GFG { static int findCost ( string s1 , string s2 , int a , int b , int c , int d , int n ) { int cost = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( s1 [ i ] == s2 [ i ] ) continue ; else { if ( ( s1 [ i ] == '1' && s2 [ i ] == '2' ) || ( s2 [ i ] == '1' && s1 [ i ] == '2' ) ) cost += Math . Min ( d , Math . Min ( a , b + c ) ) ; else if ( ( s1 [ i ] == '2' && s2 [ i ] == '3' ) || ( s2 [ i ] == '2' && s1 [ i ] == '3' ) ) cost += Math . Min ( d , Math . Min ( b , a + c ) ) ; else if ( ( s1 [ i ] == '1' && s2 [ i ] == '3' ) || ( s2 [ i ] == '1' && s1 [ i ] == '3' ) ) cost += Math . Min ( d , Math . Min ( c , a + b ) ) ; } } return cost ; } public static void Main ( ) { string s1 = "121" ; string s2 = "223" ; int a = 2 , b = 3 , c = 4 , d = 10 ; int n = s1 . Length ; Console . WriteLine ( findCost ( s1 , s2 , a , b , c , d , n ) ) ; } }

Index/key variables: i
Accumulator variables: cost, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static bool check ( string s , int k ) { for ( int i = 0 ; i < s . Length ; i ++ ) { if ( s [ i ] != s [ i % k ] ) { return false ; } } return true ; } static int countCommonDivisors ( string a , string b ) { int ct = 0 ; int n = a . Length , m = b . Length ; for ( int i = 1 ; i <= Math . Min ( n , m ) ; i ++ ) { if ( n % i == 0 && m % i == 0 ) { if ( a . Substring ( 0 , i ) == ( b . Substring ( 0 , i ) ) ) { if ( check ( a , i ) && check ( b , i ) ) { ct ++ ; } } } } return ct ; } public static void Main ( ) { string a = " xaxa " , b = " xaxaxaxa " ; Console . WriteLine ( countCommonDivisors ( a , b ) ) ; } }

Index/key variables: i
Accumulator variables: ct, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections ; class GFG { public class Node { public int data ; public Node left ; public Node right ; public Node ( int data ) { this . data = data ; left = null ; right = null ; } } static void levelOrder ( Node root ) { if ( root == null ) return ; Queue q = new Queue ( ) ; q . Enqueue ( root ) ; q . Enqueue ( null ) ; while ( q . Count > 0 ) { Node curr = ( Node ) q . Peek ( ) ; q . Dequeue ( ) ; if ( curr == null ) { if ( q . Count > 0 ) { q . Enqueue ( null ) ; Console . WriteLine ( ) ; } } else { if ( curr . left != null ) q . Enqueue ( curr . left ) ; if ( curr . right != null ) q . Enqueue ( curr . right ) ; Console . Write ( curr . data + " ▁ " ) ; } } } static public void Main ( String [ ] args ) { Node root = new Node ( 1 ) ; root . left = new Node ( 2 ) ; root . right = new Node ( 3 ) ; root . left . left = new Node ( 4 ) ; root . left . right = new Node ( 5 ) ; root . right . right = new Node ( 6 ) ; levelOrder ( root ) ; } }

Class/struct names: GFG, Node
C# program:
using System ; class GFG { static int nextZero ( int i , int [ ] occurrences ) { while ( i < occurrences . Length ) { if ( occurrences [ i ] == 0 ) return i ; i ++ ; } return - 1 ; } static string getModifiedString ( string str ) { int n = str . Length ; if ( n > 26 ) return " - 1" ; char [ ] ch = str . ToCharArray ( ) ; int [ ] occurrences = new int [ 26 ] ; int i ; for ( i = 0 ; i < n ; i ++ ) occurrences [ ch [ i ] - ' a ' ] ++ ; int index = nextZero ( 0 , occurrences ) ; for ( i = 0 ; i < n ; i ++ ) { if ( occurrences [ ch [ i ] - ' a ' ] > 1 ) { occurrences [ ch [ i ] - ' a ' ] -- ; ch [ i ] = ( char ) ( ' a ' + index ) ; occurrences [ index ] = 1 ; index = nextZero ( index + 1 , occurrences ) ; } } string s = new string ( ch ) ; return s ; } public static void Main ( ) { string str = " geeksforgeeks " ; Console . WriteLine ( getModifiedString ( str ) ) ; } }

Index/key variables: i, index
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static string extractSecretMessage ( string Str , string Sub ) { Str = Str . Replace ( Sub , " ▁ " ) ; Str = Str . Trim ( ) ; return Str ; } public static void Main ( ) { string Str = " LIELIEILIEAMLIECOOL " ; string Sub = " LIE " ; Console . WriteLine ( extractSecretMessage ( Str , Sub ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int subStringsStartingHere ( String str , int n , int startIndex ) { int count = 0 , i = startIndex + 1 ; while ( i <= n ) { if ( str . StartsWith ( str . Substring ( startIndex , i - startIndex ) ) ) { count ++ ; } else break ; i ++ ; } return count ; } static int countSubStrings ( String str , int n ) { int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( str [ i ] == str [ 0 ] ) count += subStringsStartingHere ( str , n , i ) ; } return count ; } static public void Main ( String [ ] args ) { String str = " ababc " ; int n = str . Length ; Console . WriteLine ( countSubStrings ( str , n ) ) ; } }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int binarySearch ( String [ ] arr , String x ) { int l = 0 , r = arr . Length - 1 ; while ( l <= r ) { int m = l + ( r - l ) / 2 ; int res = x . CompareTo ( arr [ m ] ) ; if ( res == 0 ) return m ; if ( res > 0 ) l = m + 1 ; else r = m - 1 ; } return - 1 ; } public static void Main ( String [ ] args ) { String [ ] arr = { " contribute " , " geeks " , " ide " , " practice " } ; String x = " ide " ; int result = binarySearch ( arr , x ) ; if ( result == - 1 ) Console . WriteLine ( " Element ▁ not ▁ present " ) ; else Console . WriteLine ( " Element ▁ found ▁ at ▁ " + " index ▁ " + result ) ; } }

Index/key variables: m
Class/struct names: GFG
C# program:
using System ; class GFG { static readonly int max_val = 257 ; static int PrimeCharacters ( String s ) { bool [ ] prime = new bool [ max_val + 1 ] ; for ( int i = 0 ; i <= max_val ; i ++ ) prime [ i ] = true ; prime [ 0 ] = false ; prime [ 1 ] = false ; for ( int p = 2 ; p * p <= max_val ; p ++ ) { if ( prime [ p ] == true ) { for ( int i = p * 2 ; i <= max_val ; i += p ) prime [ i ] = false ; } } int count = 0 ; for ( int i = 0 ; i < s . Length ; ++ i ) { if ( prime [ ( int ) ( s [ i ] ) ] ) count ++ ; } return count ; } public static void Main ( ) { String S = " geeksforgeeks " ; Console . Write ( PrimeCharacters ( S ) ) ; } }

Index/key variables: i, p
Accumulator variables: count, i, p
Iterator variables: i, p
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void getStudentsList ( string [ ] file ) { int avgScore ; int maxAvgScore = Int32 . MinValue ; List < string > names = new List < string > ( ) ; for ( int i = 0 ; i < file . Length ; i += 4 ) { avgScore = ( Int32 . Parse ( file [ i + 1 ] ) + Int32 . Parse ( file [ i + 2 ] ) + Int32 . Parse ( file [ i + 3 ] ) ) / 3 ; if ( avgScore > maxAvgScore ) { maxAvgScore = avgScore ; names . Clear ( ) ; names . Add ( file [ i ] ) ; } else if ( avgScore == maxAvgScore ) names . Add ( file [ i ] ) ; } for ( int i = 0 ; i < names . Count ; i ++ ) { Console . Write ( names [ i ] + " ▁ " ) ; } Console . WriteLine ( maxAvgScore ) ; } public static void Main ( ) { string [ ] file = { " Shrikanth " , "20" , "30" , "10" , " Ram " , "100" , "50" , "10" } ; getStudentsList ( file ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int MAX_LEN = 1005 ; static int MAX_CHAR = 26 ; static int ALL_CHARS = 256 ; static bool compare ( char [ ] arr1 , char [ ] arr2 ) { for ( int i = 0 ; i < ALL_CHARS ; i ++ ) if ( arr1 [ i ] != arr2 [ i ] ) return false ; return true ; } static bool search ( String pat , String txt ) { int M = pat . Length ; int N = txt . Length ; int i ; char [ ] countP = new char [ ALL_CHARS ] ; char [ ] countTW = new char [ ALL_CHARS ] ; for ( i = 0 ; i < M ; i ++ ) { ( countP [ pat [ i ] ] ) ++ ; ( countTW [ txt [ i ] ] ) ++ ; } for ( i = M ; i < N ; i ++ ) { if ( compare ( countP , countTW ) ) { return true ; } ( countTW [ txt [ i ] ] ) ++ ; countTW [ txt [ i - M ] ] -- ; } if ( compare ( countP , countTW ) ) return true ; return false ; } static int calculatesubString ( String s1 , String s2 , int n ) { int count = 0 , j = 0 , x = 0 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int len = 1 ; len <= n - i ; len ++ ) { if ( search ( s1 . Substring ( i , len ) , s2 ) ) { count = count + 1 ; } } } return count ; } public static void Main ( String [ ] args ) { String str1 = " PLEASEHELPIMTRAPPED " ; String str2 = " INAKICKSTARTFACTORY " ; int len = str1 . Length ; Console . WriteLine ( calculatesubString ( str1 , str2 , len ) ) ; } }

Index/key variables: ALL_CHARS, i
Accumulator variables: i, len
Iterator variables: i, len
Class/struct names: GFG
C# program:
using System ; class GFG { static int strScore ( String [ ] str , String s , int n ) { int score = 0 , index = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( str [ i ] == s ) { for ( int j = 0 ; j < s . Length ; j ++ ) score += s [ j ] - ' a ' + 1 ; index = i + 1 ; break ; } } score = score * index ; return score ; } public static void Main ( String [ ] args ) { String [ ] str = { " sahil " , " shashanak " , " sanjit " , " abhinav " , " mohit " } ; String s = " abhinav " ; int n = str . Length ; int score = strScore ( str , s , n ) ; Console . Write ( score ) ; } }

Index/key variables: i, j
Accumulator variables: i, j, score
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static bool sameJavaharAdj ( char [ ] str ) { int n = str . Length , i ; HashSet < char > st = new HashSet < char > ( ) ; st . Add ( str [ 0 ] ) ; for ( i = 1 ; i < n ; i ++ ) { if ( str [ i ] == str [ i - 1 ] ) { continue ; } if ( st . Contains ( str [ i ] ) & ! st . Equals ( str [ i ] ) ) { return false ; } st . Add ( str [ i ] ) ; } return true ; } static int minSwaps ( char [ ] str , int l , int r , int cnt , int minm ) { if ( l == r ) { if ( sameJavaharAdj ( str ) ) { return cnt ; } else { return int . MaxValue ; } } for ( int i = l + 1 ; i <= r ; i ++ ) { swap ( str , i , l ) ; cnt ++ ; int x = minSwaps ( str , l + 1 , r , cnt , minm ) ; swap ( str , i , l ) ; cnt -- ; int y = minSwaps ( str , l + 1 , r , cnt , minm ) ; minm = Math . Min ( minm , Math . Min ( x , y ) ) ; } return minm ; } static void swap ( char [ ] arr , int i , int j ) { char temp = arr [ i ] ; arr [ i ] = arr [ j ] ; arr [ j ] = temp ; } public static void Main ( ) { String str = " abbaacb " ; int n = str . Length , cnt = 0 , minm = int . MaxValue ; Console . WriteLine ( minSwaps ( str . ToCharArray ( ) , 0 , n - 1 , cnt , minm ) ) ; ; } }

Index/key variables: i, j
Accumulator variables: cnt, i
Iterator variables: i
Class/struct names: GFG
C# program:
static int find ( int [ ] parent , int i ) { if ( parent [ i ] == - 1 ) return i ; return find ( parent , parent [ i ] ) ; } static void Union ( int [ ] parent , int x , int y ) { int xset = find ( parent , x ) ; int yset = find ( parent , y ) ; parent [ xset ] = yset ; }

Index/key variables: i, xset
C# program:
using System ; class GFG { static String K_thletter ( String S , int K ) { int N = S . Length ; long size = 0 ; for ( int i = 0 ; i < N ; ++ i ) { if ( char . IsDigit ( S [ i ] ) ) { size = size * ( S [ i ] - '0' ) ; } else { size += 1 ; } } for ( int i = N - 1 ; i >= 0 ; -- i ) { K %= ( int ) size ; if ( K == 0 && char . IsLetter ( S [ i ] ) ) { return ( String ) " " + S [ i ] ; } if ( char . IsDigit ( S [ i ] ) ) { size = size / ( S [ i ] - '0' ) ; } else { size -= 1 ; } } return null ; } public static void Main ( String [ ] args ) { String S = " geeks2for2" ; int K = 15 ; Console . WriteLine ( K_thletter ( S , K ) ) ; } }

Index/key variables: i
Accumulator variables: size
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int minParentheses ( string p ) { int bal = 0 ; int ans = 0 ; for ( int i = 0 ; i < p . Length ; ++ i ) { bal += p [ i ] == ' ( ' ? 1 : - 1 ; if ( bal == - 1 ) { ans += 1 ; bal += 1 ; } } return bal + ans ; } public static void Main ( ) { string p = " ( ) ) " ; Console . WriteLine ( minParentheses ( p ) ) ; } }

Index/key variables: i
Accumulator variables: ans, bal
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static String reverse ( String input ) { char [ ] a = input . ToCharArray ( ) ; int l , r = 0 ; 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 ) ; } static Boolean isPalindrome ( String r ) { String p = r ; p = reverse ( p ) ; return ( r . Equals ( p ) ) ; } static Boolean CheckStr ( String s ) { int l = s . Length ; int i ; for ( i = 2 ; i <= l ; i ++ ) { if ( isPalindrome ( s . Substring ( 0 , i ) ) ) { break ; } } if ( i == ( l + 1 ) ) { return false ; } i = 2 ; for ( i = 2 ; i <= l ; i ++ ) { if ( isPalindrome ( s . Substring ( l - i , i ) ) ) { return true ; } } return false ; } public static void Main ( String [ ] args ) { String s = " abccbarfgdbd " ; if ( CheckStr ( s ) ) { Console . WriteLine ( " Yes " ) ; } else { Console . WriteLine ( " No " ) ; } } }

Index/key variables: l, r
Accumulator variables: i, l, r
Iterator variables: i, l
Class/struct names: GFG
C# program:
using System ; class GFG { static int oddEquivalent ( String s , int n ) { int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( s [ i ] == '1' ) count ++ ; } return count ; } public static void Main ( ) { String s = "1011011" ; int n = s . Length ; Console . WriteLine ( oddEquivalent ( s , 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 MAX = 256 ; static int minimumOperation ( String s ) { int n = s . Length ; List < int > first_occ = new List < int > ( ) ; for ( int i = 0 ; i < MAX ; i ++ ) first_occ . Insert ( i , - 1 ) ; int res = int . MaxValue ; for ( int i = 0 ; i < n ; i ++ ) { int x = ( int ) s [ i ] ; if ( first_occ [ x ] == - 1 ) first_occ . Insert ( x , i ) ; else { int last_occ = ( n - i - 1 ) ; res = Math . Min ( res , first_occ [ x ] + last_occ ) ; } } return res ; } public static void Main ( String [ ] args ) { String s = " bacdefghipalop " ; Console . WriteLine ( minimumOperation ( s ) ) ; } }

Index/key variables: i, x
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int CompareTo ( String s1 , String s2 ) { for ( int i = 0 ; i < s1 . Length < s2 . Length ; i ++ ) { if ( s1 [ i ] < s2 [ i ] ) return - 1 ; else if ( s1 [ i ] > s2 [ i ] ) return 1 ; } return 0 ; } static void getSmallestAndLargest ( String s , int k ) { String currStr = s . Substring ( 0 , k ) ; String lexMin = currStr ; String lexMax = currStr ; for ( int i = k ; i < s . Length ; i ++ ) { currStr = currStr . Substring ( 1 , k - 1 ) + " " + s [ i ] ; if ( CompareTo ( lexMax , currStr ) < 0 ) lexMax = currStr ; if ( CompareTo ( lexMin , currStr ) > 0 ) lexMin = currStr ; } Console . WriteLine ( lexMin ) ; Console . WriteLine ( lexMax ) ; } public static void Main ( String [ ] args ) { String str = " GeeksForGeeks " ; int k = 3 ; getSmallestAndLargest ( str , k ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class Initials { public static void printInitials ( string str ) { int len = str . Length ; str = str . Trim ( ) ; String t = " " ; for ( int i = 0 ; i < len ; i ++ ) { char ch = str [ i ] ; if ( ch != ' ▁ ' ) { t = t + ch ; } else { Console . Write ( Char . ToUpper ( t [ 0 ] ) + " . ▁ " ) ; t = " " ; } } string temp = " " ; for ( int j = 0 ; j < t . Length ; j ++ ) { if ( j == 0 ) temp = temp + Char . ToUpper ( t [ 0 ] ) ; else temp = temp + Char . ToLower ( t [ j ] ) ; } Console . WriteLine ( temp ) ; } public static void Main ( ) { string str = " ishita ▁ bhuiya " ; printInitials ( str ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: Initials
C# program:
using System ; class GFG { static int findNumberOfTimes ( String str1 , String str2 ) { int [ ] freq = new int [ 26 ] ; int l1 = str1 . Length ; int [ ] freq2 = new int [ 26 ] ; int l2 = str2 . Length ; for ( int i = 0 ; i < l1 ; i ++ ) { freq [ str1 [ i ] - ' a ' ] += 1 ; } for ( int i = 0 ; i < l2 ; i ++ ) { freq2 [ str2 [ i ] - ' a ' ] += 1 ; } int count = int . MaxValue ; for ( int i = 0 ; i < l2 ; i ++ ) { if ( freq2 [ str2 [ i ] - ' a ' ] != 0 ) count = Math . Min ( count , freq [ str2 [ i ] - ' a ' ] / freq2 [ str2 [ i ] - ' a ' ] ) ; } return count ; } public static void Main ( ) { String str1 = " foreeksgekseg " ; String str2 = " geeks " ; Console . Write ( findNumberOfTimes ( str1 , str2 ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static bool solve ( String s1 , String s2 ) { bool flag1 = false , flag2 = false ; if ( s1 . Length != s2 . Length ) return false ; int l = s1 . Length ; for ( int i = 0 ; i < l ; i ++ ) { if ( s1 [ i ] == '1' ) flag1 = true ; if ( s2 [ i ] == '1' ) flag2 = true ; if ( flag1 == true && flag2 == true ) return true ; } if ( ! flag1 && ! flag2 ) return true ; return false ; } public static void Main ( ) { String s1 = "100101" ; String s2 = "100000" ; if ( solve ( s1 , s2 ) == true ) Console . Write ( " Yes " ) ; else Console . Write ( " No " ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Boolean variables: flag1, flag2
Class/struct names: GFG
C# program:
using System ; class GFG { static char nextGreatestAlphabet ( char [ ] alphabets , char K ) { int n = alphabets . Length ; if ( K >= alphabets [ n - 1 ] ) return alphabets [ 0 ] ; int l = 0 , r = alphabets . Length - 1 ; int ans = - 1 ; while ( l <= r ) { int mid = ( l + r ) / 2 ; if ( alphabets [ mid ] > K ) { ans = mid ; r = mid - 1 ; } else l = mid + 1 ; } return alphabets [ ans ] ; } public static void Main ( ) { char [ ] letters = { ' A ' , ' r ' , ' z ' } ; char K = ' z ' ; char result = nextGreatestAlphabet ( letters , K ) ; Console . Write ( result ) ; } }

Index/key variables: ans, mid
Class/struct names: GFG
C# program:
using System ; class GFG { public static int subzero ( String s , int k ) { int ans = 0 , curr = 0 ; int len = s . Length ; char [ ] str = s . ToCharArray ( ) ; for ( int i = 0 ; i < len ; ++ i ) { if ( str [ i ] == '0' ) curr ++ ; else curr = 0 ; ans = Math . Max ( ans , curr ) ; } if ( ans == len ) return len * k ; else { int pre = 0 , suff = 0 ; for ( int i = 0 ; i < len ; i ++ ) { if ( str [ i ] == '0' ) pre ++ ; else break ; } for ( int i = len - 1 ; i >= 0 ; i -- ) { if ( str [ i ] == '0' ) suff ++ ; else break ; } if ( k > 1 ) ans = Math . Max ( ans , pre + suff ) ; return ans ; } } public static void Main ( ) { String str = "00100110" ; int k = 5 ; Console . Write ( subzero ( str , k ) ) ; } }

Index/key variables: i
Accumulator variables: curr, i, pre, suff
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static String Dragon_Curve_Sequence ( int n ) { String s = "1" ; for ( int i = 2 ; i <= n ; i ++ ) { String temp = "1" ; char prev = '1' , zero = '0' , one = '1' ; for ( int j = 0 ; j < s . Length ; j ++ ) { temp += s [ j ] ; if ( prev == '0' ) { temp += one ; prev = one ; } else { temp += zero ; prev = zero ; } } s = temp ; } return s ; } public static void Main ( ) { int n = 4 ; String s = Dragon_Curve_Sequence ( n ) ; Console . WriteLine ( s ) ; } }

Index/key variables: j
Accumulator variables: i, j, temp
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int countNonEmptySubstr ( string str ) { int n = str . Length ; return n * ( n + 1 ) / 2 ; } public static void Main ( ) { string s = " abcde " ; Console . Write ( countNonEmptySubstr ( s ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { public static int findSubstrings ( string s , int k ) { int ans = 0 ; int [ ] cnt = new int [ 26 ] ; int i , j , n = s . Length ; for ( i = 0 ; i < n ; i ++ ) { Array . Clear ( cnt , 0 , cnt . Length ) ; for ( j = i ; j < n ; j ++ ) { cnt [ s [ j ] - ' a ' ] ++ ; if ( cnt [ s [ j ] - ' a ' ] <= k ) ans ++ ; else break ; } } return ans ; } public static int Main ( ) { string S = " aaabb " ; int k = 2 ; Console . WriteLine ( findSubstrings ( S , k ) ) ; return 0 ; } }

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