dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; class GFG { static String MinValue ( string number , int x ) { int length = number . Length ; int position = length + 1 ; if ( number [ 0 ] == ' - ' ) { for ( int i = number . Length - 1 ; i >= 1 ; -- i ) { if ( ( number [ i ] - 48 ) < x ) { position = i ; } } } else { for ( int i = number . Length - 1 ; i >= 0 ; -- i ) { if ( ( number [ i ] - 48 ) > x ) { position = i ; } } } number = number . Substring ( 0 , position ) + x + number . Substring ( position , number . Length ) ; return number . ToString ( ) ; } public static void Main ( ) { string number = "89" ; int x = 1 ; Console . WriteLine ( MinValue ( number , x ) ) ; } }

Index/key variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public static String divisibleByk ( String s , int n , int k ) { int [ ] poweroftwo = new int [ n ] ; poweroftwo [ 0 ] = 1 % k ; for ( int i = 1 ; i < n ; i ++ ) { poweroftwo [ i ] = ( poweroftwo [ i - 1 ] * ( 2 % k ) ) % k ; } int rem = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( s [ n - i - 1 ] == '1' ) { rem += ( poweroftwo [ i ] ) ; rem %= k ; } } if ( rem == 0 ) { return " Yes " ; } else return " No " ; } public static void Main ( String [ ] args ) { String s = "1010001" ; int k = 9 ; int n = s . Length ; Console . Write ( divisibleByk ( s , n , k ) ) ; } }

Index/key variables: i, n
Accumulator variables: i, rem
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static int maxSumbySplittingString ( String str , int N ) { int cntOne = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( str [ i ] == '1' ) { cntOne ++ ; } } int zero = 0 ; int one = 0 ; int res = 0 ; for ( int i = 0 ; i < N - 1 ; i ++ ) { if ( str [ i ] == '0' ) { zero ++ ; } else { one ++ ; } res = Math . Max ( res , zero + cntOne - one ) ; } return res ; } public static void Main ( String [ ] args ) { String str = "00111" ; int N = str . Length ; Console . Write ( maxSumbySplittingString ( str , N ) ) ; } }

Index/key variables: i
Accumulator variables: cntOne, i, one, zero
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void cntBalancedParenthesis ( String s , int N ) { int cntPairs = 0 ; int cntCurly = 0 ; int cntSml = 0 ; int cntSqr = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( s [ i ] == ' { ' ) { cntCurly ++ ; } else if ( s [ i ] == ' ( ' ) { cntSml ++ ; } else if ( s [ i ] == ' [ ' ) { cntSqr ++ ; } else if ( s [ i ] == ' } ' && cntCurly > 0 ) { cntCurly -- ; cntPairs ++ ; } else if ( s [ i ] == ' ) ' && cntSml > 0 ) { cntSml -- ; cntPairs ++ ; } else if ( s [ i ] == ' ] ' && cntSqr > 0 ) { cntSqr -- ; cntPairs ++ ; } } Console . WriteLine ( cntPairs ) ; } static public void Main ( ) { String s = " { ( } ) " ; int N = s . Length ; cntBalancedParenthesis ( s , N ) ; } }

Index/key variables: i
Accumulator variables: cntCurly, cntPairs, cntSml, cntSqr, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int arcIntersection ( String S , int len ) { Stack < char > stk = new Stack < char > ( ) ; for ( int i = 0 ; i < len ; i ++ ) { stk . Push ( S [ i ] ) ; if ( stk . Count >= 2 ) { char temp = stk . Peek ( ) ; stk . Pop ( ) ; if ( stk . Peek ( ) == temp ) { stk . Pop ( ) ; } else { stk . Push ( temp ) ; } } } if ( stk . Count == 0 ) return 1 ; return 0 ; } static void countString ( String [ ] arr , int N ) { int count = 0 ; for ( int i = 0 ; i < N ; i ++ ) { int len = arr [ i ] . Length ; count += arcIntersection ( arr [ i ] , len ) ; } Console . Write ( count + " STRNEWLINE " ) ; } public static void Main ( String [ ] args ) { String [ ] arr = { "0101" , "0011" , "0110" } ; int N = arr . Length ; countString ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static String ConvertequivalentBase8 ( String S ) { Dictionary < String , char > mp = new Dictionary < String , char > ( ) ; mp . Add ( "000" , '0' ) ; mp . Add ( "001" , '1' ) ; mp . Add ( "010" , '2' ) ; mp . Add ( "011" , '3' ) ; mp . Add ( "100" , '4' ) ; mp . Add ( "101" , '5' ) ; mp . Add ( "110" , '6' ) ; mp . Add ( "111" , '7' ) ; int N = S . Length ; if ( N % 3 == 2 ) { S = "0" + S ; } else if ( N % 3 == 1 ) { S = "00" + S ; } N = S . Length ; String oct = " " ; for ( int i = 0 ; i < N ; i += 3 ) { String temp = S . Substring ( 0 , N ) ; if ( mp . ContainsKey ( temp ) ) oct += mp [ temp ] ; } return oct ; } static String binString_div_9 ( String S , int N ) { String oct = " " ; oct = ConvertequivalentBase8 ( S ) ; int oddSum = 0 ; int evenSum = 0 ; int M = oct . Length ; for ( int i = 0 ; i < M ; i += 2 ) oddSum += ( oct [ i ] - '0' ) ; for ( int i = 1 ; i < M ; i += 2 ) { evenSum += ( oct [ i ] - '0' ) ; } int Oct_9 = 11 ; if ( Math . Abs ( oddSum - evenSum ) % Oct_9 == 0 ) { return " Yes " ; } return " No " ; } public static void Main ( String [ ] args ) { String S = "1010001" ; int N = S . Length ; Console . WriteLine ( binString_div_9 ( S , N ) ) ; } }

Index/key variables: i, temp
Accumulator variables: evenSum, i, oct, oddSum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int min_cost ( String S ) { int cost = 0 ; int F = 0 ; int B = 0 ; int count = 0 ; foreach ( char c in S . ToCharArray ( ) ) if ( c == ' ▁ ' ) count ++ ; int n = S . Length - count ; if ( n == 1 ) return cost ; foreach ( char inn in S . ToCharArray ( ) ) { if ( inn != ' ▁ ' ) { if ( B != 0 ) { cost += Math . Min ( n - F , F ) * B ; B = 0 ; } F += 1 ; } else { B += 1 ; } } return cost ; } public static void Main ( String [ ] args ) { String S = " ▁ @ TABSYMBOL $ " ; Console . WriteLine ( min_cost ( S ) ) ; } }

Accumulator variables: B, F, cost, count
Iterator variables: c, inn
Class/struct names: GFG
C# program:
using System ; class GFG { static bool isVowel ( char ch ) { if ( ch == ' a ' ch == ' e ' ch == ' i ' ch == ' o ' ch == ' u ' ) return true ; else return false ; } static int minCost ( String S ) { int cA = 0 ; int cE = 0 ; int cI = 0 ; int cO = 0 ; int cU = 0 ; for ( int i = 0 ; i < S . Length ; i ++ ) { if ( isVowel ( S [ i ] ) ) { cA += Math . Abs ( S [ i ] - ' a ' ) ; cE += Math . Abs ( S [ i ] - ' e ' ) ; cI += Math . Abs ( S [ i ] - ' i ' ) ; cO += Math . Abs ( S [ i ] - ' o ' ) ; cU += Math . Abs ( S [ i ] - ' u ' ) ; } } return Math . Min ( Math . Min ( Math . Min ( Math . Min ( cA , cE ) , cI ) , cO ) , cU ) ; } public static void Main ( String [ ] args ) { String S = " geeksforgeeks " ; Console . WriteLine ( minCost ( S ) ) ; } }

Index/key variables: i
Accumulator variables: cA, cE, cI, cO, cU, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public static void decode_String ( String str , int K ) { String ans = " " ; for ( int i = 0 ; i < str . Length ; i += K ) ans += str [ i ] ; for ( int i = str . Length - ( K - 1 ) ; i < str . Length ; i ++ ) ans += str [ i ] ; Console . WriteLine ( ans ) ; } public static void Main ( String [ ] args ) { int K = 3 ; String str = " abcbcscsesesesd " ; decode_String ( str , K ) ; } }

Index/key variables: i
Accumulator variables: ans, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static string maxVowelSubString ( string str , int K ) { int N = str . Length ; int [ ] pref = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { if ( str [ i ] == ' a ' str [ i ] == ' e ' str [ i ] == ' i ' str [ i ] == ' o ' str [ i ] == ' u ' ) pref [ i ] = 1 ; else pref [ i ] = 0 ; if ( i != 0 ) pref [ i ] += pref [ i - 1 ] ; } int maxCount = pref [ K - 1 ] ; string res = str . Substring ( 0 , K ) ; for ( int i = K ; i < N ; i ++ ) { int currCount = pref [ i ] - pref [ i - K ] ; if ( currCount > maxCount ) { maxCount = currCount ; res = str . Substring ( i - K + 1 , K ) ; } else if ( currCount == maxCount ) { string temp = str . Substring ( i - K + 1 , K ) ; if ( string . Compare ( temp , res ) == - 1 ) res = temp ; } } return res ; } public static void Main ( ) { string str = " ceebbaceeffo " ; int K = 3 ; Console . Write ( maxVowelSubString ( str , K ) ) ; } }

Index/key variables: N, i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void decodeStr ( String str , int len ) { char [ ] c = new char [ len ] ; int med , pos = 1 , k ; if ( len % 2 == 1 ) med = len / 2 ; else med = len / 2 - 1 ; c [ med ] = str [ 0 ] ; if ( len % 2 == 0 ) c [ med + 1 ] = str [ 1 ] ; if ( len % 2 == 1 ) k = 1 ; else k = 2 ; for ( int i = k ; i < len ; i += 2 ) { c [ med - pos ] = str [ i ] ; if ( len % 2 == 1 ) c [ med + pos ] = str [ i + 1 ] ; else c [ med + pos + 1 ] = str [ i + 1 ] ; pos ++ ; } for ( int i = 0 ; i < len ; i ++ ) Console . Write ( c [ i ] ) ; } public static void Main ( String [ ] args ) { String str = " ofrsgkeeeekgs " ; int len = str . Length ; decodeStr ( str , len ) ; } }

Index/key variables: i, len, med
Accumulator variables: i, pos
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void findCount ( String s , int L , int R ) { int distinct = 0 ; int [ ] frequency = new int [ 26 ] ; for ( int i = L ; i <= R ; i ++ ) { frequency [ s [ i ] - ' a ' ] ++ ; } for ( int i = 0 ; i < 26 ; i ++ ) { if ( frequency [ i ] > 0 ) distinct ++ ; } Console . Write ( distinct + " STRNEWLINE " ) ; } public static void Main ( String [ ] args ) { String s = " geeksforgeeksisa " + " computerscienceportal " ; int queries = 3 ; int [ , ] Q = { { 0 , 10 } , { 15 , 18 } , { 12 , 20 } } ; for ( int i = 0 ; i < queries ; i ++ ) findCount ( s , Q [ i , 0 ] , Q [ i , 1 ] ) ; } }

Index/key variables: i
Accumulator variables: distinct, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static string ReverseComplement ( char [ ] s , int n , int k ) { int rev = ( k + 1 ) / 2 ; int complement = k - rev ; if ( rev % 2 == 1 ) s = reverse ( s ) ; if ( complement % 2 == 1 ) { for ( int i = 0 ; i < n ; i ++ ) { if ( s [ i ] == '0' ) s [ i ] = '1' ; else s [ i ] = '0' ; } } return ( new string ( s ) ) ; } static char [ ] reverse ( char [ ] a ) { int i , n = a . Length ; char t ; for ( i = 0 ; i < n / 2 ; i ++ ) { t = a [ i ] ; a [ i ] = a [ n - i - 1 ] ; a [ n - i - 1 ] = t ; } return a ; } public static void Main ( ) { string str = "10011" ; int k = 5 ; int n = str . Length ; Console . Write ( ReverseComplement ( str . ToCharArray ( ) , n , k ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static bool repeatingString ( String s , int n , int k ) { if ( n % k != 0 ) { return false ; } int [ ] frequency = new int [ 123 ] ; for ( int i = 0 ; i < 123 ; i ++ ) { frequency [ i ] = 0 ; } for ( int i = 0 ; i < n ; i ++ ) { frequency [ s [ i ] ] ++ ; } int repeat = n / k ; for ( int i = 0 ; i < 123 ; i ++ ) { if ( frequency [ i ] % repeat != 0 ) { return false ; } } return true ; } public static void Main ( String [ ] args ) { String s = " abcdcba " ; int n = s . Length ; int k = 3 ; if ( repeatingString ( s , n , k ) ) { Console . Write ( " Yes " + " STRNEWLINE " ) ; } else { Console . Write ( " No " + " STRNEWLINE " ) ; } } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void findPhoneNumber ( int n ) { int temp = n ; int sum = 0 ; while ( temp != 0 ) { sum += temp % 10 ; temp = temp / 10 ; } if ( sum < 10 ) Console . Write ( n + "0" + sum ) ; else Console . Write ( n + " " + sum ) ; } static public void Main ( ) { int n = 98765432 ; findPhoneNumber ( n ) ; } }

Accumulator variables: sum
Class/struct names: GFG
C# program:
using System ; class GFG { static int maxN = 20 ; static int maxM = 64 ; static int cntSplits ( String s ) { if ( s [ s . Length - 1 ] == '1' ) return 0 ; int c_zero = 0 ; for ( int i = 0 ; i < s . Length ; i ++ ) c_zero += ( s [ i ] == '0' ) ? 1 : 0 ; return ( int ) Math . Pow ( 2 , c_zero - 1 ) ; } public static void Main ( String [ ] args ) { String s = "10010" ; Console . WriteLine ( cntSplits ( s ) ) ; } }

Index/key variables: i
Accumulator variables: c_zero, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void findNumbers ( String s ) { int n = s . Length ; int count = 1 ; int result = 0 ; int left = 0 ; int right = 1 ; while ( right < n ) { if ( s [ left ] == s [ right ] ) count ++ ; else { result += count * ( count + 1 ) / 2 ; left = right ; count = 1 ; } right ++ ; } result += count * ( count + 1 ) / 2 ; Console . WriteLine ( result ) ; } public static void Main ( String [ ] args ) { String s = " bbbcbb " ; findNumbers ( s ) ; } }

Index/key variables: left, right
Accumulator variables: count, result, right
Class/struct names: GFG
C# program:
using System ; class GFG { static bool isVowel ( char ch ) { ch = char . ToUpper ( ch ) ; return ( ch == ' A ' ch == ' E ' ch == ' I ' ch == ' O ' ch == ' U ' ) ; } static String duplicateVowels ( String str ) { int t = str . Length ; String res = " " ; for ( int i = 0 ; i < t ; i ++ ) { if ( isVowel ( str [ i ] ) ) res += str [ i ] ; res += str [ i ] ; } return res ; } public static void Main ( String [ ] args ) { String str = " helloworld " ; Console . WriteLine ( " Original ▁ String : ▁ " + str ) ; String res = duplicateVowels ( str ) ; Console . WriteLine ( " String ▁ with ▁ Vowels ▁ duplicated : ▁ " + res ) ; } }

Index/key variables: i
Accumulator variables: i, res
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int stringToInt ( String str ) { if ( str . Length == 1 ) return ( str [ 0 ] - '0' ) ; double y = stringToInt ( str . Substring ( 1 ) ) ; double x = str [ 0 ] - '0' ; x = x * Math . Pow ( 10 , str . Length - 1 ) + y ; return ( int ) ( x ) ; } public static void Main ( String [ ] args ) { String str = "1235" ; Console . Write ( stringToInt ( str ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int MAX = 26 ; static int largestSubSeq ( string [ ] arr , int n ) { int [ ] count = new int [ MAX ] ; for ( int i = 0 ; i < n ; i ++ ) { string str = arr [ i ] ; bool [ ] hash = new bool [ MAX ] ; for ( int j = 0 ; j < str . Length ; j ++ ) { hash [ str [ j ] - ' a ' ] = true ; } for ( int j = 0 ; j < MAX ; j ++ ) { if ( hash [ j ] ) count [ j ] ++ ; } } int max = - 1 ; for ( int i = 0 ; i < MAX ; i ++ ) { if ( max < count [ i ] ) max = count [ i ] ; } return max ; } public static void Main ( ) { string [ ] arr = { " ab " , " bc " , " de " } ; int n = arr . Length ; Console . WriteLine ( largestSubSeq ( arr , n ) ) ; } }

Index/key variables: MAX, i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static bool isPalindrome ( string str ) { int len = str . Length ; for ( int i = 0 ; i < len / 2 ; i ++ ) { if ( str [ i ] != str [ len - 1 - i ] ) return false ; } return true ; } static bool createStringAndCheckPalindrome ( int N ) { string sub = " " + N , res_str = " " ; int sum = 0 ; while ( N > 0 ) { int digit = N % 10 ; sum += digit ; N = N / 10 ; } while ( res_str . Length < sum ) res_str += sub ; if ( res_str . Length > sum ) res_str = res_str . Substring ( 0 , sum ) ; if ( isPalindrome ( res_str ) ) return true ; return false ; } public static void Main ( ) { int N = 10101 ; if ( createStringAndCheckPalindrome ( N ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }

Index/key variables: i
Accumulator variables: i, res_str, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int minimumLength ( String s ) { int maxOcc = 0 , n = s . Length ; int [ ] arr = new int [ 26 ] ; for ( int i = 0 ; i < n ; i ++ ) arr [ s [ i ] - ' a ' ] ++ ; for ( int i = 0 ; i < 26 ; i ++ ) if ( arr [ i ] > maxOcc ) maxOcc = arr [ i ] ; return ( n - maxOcc ) ; } public static void Main ( String [ ] args ) { String str = " afddewqd " ; Console . WriteLine ( minimumLength ( str ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void removeSpecialCharacter ( string s ) { for ( int i = 0 ; i < s . Length ; i ++ ) { if ( s [ i ] < ' A ' s [ i ] > ' Z ' && s [ i ] < ' a ' s [ i ] > ' z ' ) { s = s . Remove ( i , 1 ) ; i -- ; } } Console . Write ( s ) ; } public static void Main ( ) { string s = " $ Gee * k ; s . . fo , ▁ r ' Ge ^ eks ? " ; removeSpecialCharacter ( s ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static void removeSpecialCharacter ( String str ) { char [ ] s = str . ToCharArray ( ) ; int j = 0 ; for ( int i = 0 ; i < s . Length ; i ++ ) { if ( ( s [ i ] >= ' A ' && s [ i ] <= ' Z ' ) || ( s [ i ] >= ' a ' && s [ i ] <= ' z ' ) ) { s [ j ] = s [ i ] ; j ++ ; } } Console . WriteLine ( String . Join ( " " , s ) . Substring ( 0 , j ) ) ; } public static void Main ( ) { String s = " $ Gee * k ; s . . fo , ▁ r ' Ge ^ eks ? " ; removeSpecialCharacter ( s ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int findRepeatFirstN2 ( string s ) { int p = - 1 , i , j ; for ( i = 0 ; i < s . Length ; i ++ ) { for ( j = i + 1 ; j < s . Length ; j ++ ) { if ( s [ i ] == s [ j ] ) { p = i ; break ; } } if ( p != - 1 ) break ; } return p ; } static public void Main ( ) { string str = " geeksforgeeks " ; int pos = findRepeatFirstN2 ( str ) ; if ( pos == - 1 ) Console . WriteLine ( " Not ▁ found " ) ; else Console . WriteLine ( str [ pos ] ) ; } }

Index/key variables: i, j, pos
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections ; using System . Collections . Generic ; class GFG { public static void prCharWithFreq ( string s ) { Dictionary < char , int > d = new Dictionary < char , int > ( ) ; foreach ( char i in s ) { if ( d . ContainsKey ( i ) ) { d [ i ] ++ ; } else { d [ i ] = 1 ; } } foreach ( char i in s ) { if ( d [ i ] != 0 ) { Console . Write ( i + d [ i ] . ToString ( ) + " ▁ " ) ; d [ i ] = 0 ; } } } public static void Main ( string [ ] args ) { string s = " geeksforgeeks " ; prCharWithFreq ( s ) ; } }

Index/key variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int possibleStrings ( int n , int r , int b , int g ) { int [ ] fact = new int [ n + 1 ] ; fact [ 0 ] = 1 ; for ( int i = 1 ; i <= n ; i ++ ) fact [ i ] = fact [ i - 1 ] * i ; int left = n - ( r + g + b ) ; int sum = 0 ; for ( int i = 0 ; i <= left ; i ++ ) { for ( int j = 0 ; j <= left - i ; j ++ ) { int k = left - ( i + j ) ; sum = sum + fact [ n ] / ( fact [ i + r ] * fact [ j + b ] * fact [ k + g ] ) ; } } return sum ; } public static void Main ( ) { int n = 4 , r = 2 ; int b = 0 , g = 1 ; Console . WriteLine ( possibleStrings ( n , r , b , g ) ) ; } }

Index/key variables: i, n
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int remAnagram ( string str1 , string str2 ) { int [ ] count1 = new int [ 26 ] ; int [ ] count2 = new int [ 26 ] ; for ( int i = 0 ; i < str1 . Length ; i ++ ) count1 [ str1 [ i ] - ' a ' ] ++ ; for ( int i = 0 ; i < str2 . Length ; i ++ ) count2 [ str2 [ i ] - ' a ' ] ++ ; int result = 0 ; for ( int i = 0 ; i < 26 ; i ++ ) result += Math . Abs ( count1 [ i ] - count2 [ i ] ) ; return result ; } public static void Main ( ) { string str1 = " bcadeh " , str2 = " hea " ; Console . Write ( remAnagram ( str1 , str2 ) ) ; } }

Index/key variables: i
Accumulator variables: i, result
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static int CHARS = 26 ; static bool isValidString ( String str ) { int [ ] freq = new int [ CHARS ] ; int i = 0 ; for ( i = 0 ; i < str . Length ; i ++ ) { freq [ str [ i ] - ' a ' ] ++ ; } int freq1 = 0 , count_freq1 = 0 ; for ( i = 0 ; i < CHARS ; i ++ ) { if ( freq [ i ] != 0 ) { freq1 = freq [ i ] ; count_freq1 = 1 ; break ; } } int j , freq2 = 0 , count_freq2 = 0 ; for ( j = i + 1 ; j < CHARS ; j ++ ) { if ( freq [ j ] != 0 ) { if ( freq [ j ] == freq1 ) { count_freq1 ++ ; } else { count_freq2 = 1 ; freq2 = freq [ j ] ; break ; } } } for ( int k = j + 1 ; k < CHARS ; k ++ ) { if ( freq [ k ] != 0 ) { if ( freq [ k ] == freq1 ) { count_freq1 ++ ; } if ( freq [ k ] == freq2 ) { count_freq2 ++ ; { return false ; } } if ( count_freq1 > 1 && count_freq2 > 1 ) { return false ; } } return true ; } public static void Main ( ) { String str = " abcbc " ; if ( isValidString ( str ) ) { Console . WriteLine ( " YES " ) ; } else { Console . WriteLine ( " NO " ) ; } } }

Index/key variables: CHARS, i, j, k
Accumulator variables: count_freq1, count_freq2, i, j, k
Iterator variables: i, j, k
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; public class AllCharsWithSameFrequencyWithOneVarAllowed { public static bool checkForVariation ( String str ) { if ( str == null str . Length != 0 ) { return true ; } Dictionary < char , int > map = new Dictionary < char , int > ( ) ; for ( int i = 0 ; i < str . Length ; i ++ ) { if ( map . ContainsKey ( str [ i ] ) ) map [ str [ i ] ] = map [ str [ i ] ] + 1 ; else map . Add ( str [ i ] , 1 ) ; } bool first = true , second = true ; int val1 = 0 , val2 = 0 ; int countOfVal1 = 0 , countOfVal2 = 0 ; foreach ( KeyValuePair < char , int > itr in map ) { int i = itr . Key ; if ( first ) { val1 = i ; first = false ; countOfVal1 ++ ; continue ; } if ( i == val1 ) { countOfVal1 ++ ; continue ; } if ( second ) { val2 = i ; countOfVal2 ++ ; second = false ; continue ; } if ( i == val2 ) { countOfVal2 ++ ; continue ; } return false ; } if ( countOfVal1 > 1 && countOfVal2 > 1 ) { return false ; } else { return true ; } } public static void Main ( String [ ] args ) { Console . WriteLine ( checkForVariation ( " abcbc " ) ) ; } }

Index/key variables: i
Accumulator variables: countOfVal1, countOfVal2, i
Iterator variables: i, itr
Boolean variables: first, second
Class/struct names: AllCharsWithSameFrequencyWithOneVarAllowed
C# program:
using System ; class GFG { static int countCompletePairs ( string [ ] set1 , string [ ] set2 , int n , int m ) { int result = 0 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { string concat = set1 [ i ] + set2 [ j ] ; int [ ] frequency = new int [ 26 ] ; for ( int k = 0 ; k < concat . Length ; k ++ ) { frequency [ concat [ k ] - ' a ' ] ++ ; } int l ; for ( l = 0 ; l < 26 ; l ++ ) { if ( frequency [ l ] < 1 ) { break ; } } if ( l == 26 ) { result ++ ; } } } return result ; } static public void Main ( ) { string [ ] set1 = { " abcdefgh " , " geeksforgeeks " , " lmnopqrst " , " abc " } ; string [ ] set2 = { " ijklmnopqrstuvwxyz " , " abcdefghijklmnopqrstuvwxyz " , " defghijklmnopqrstuvwxyz " } ; int n = set1 . Length ; int m = set2 . Length ; Console . Write ( countCompletePairs ( set1 , set2 , n , m ) ) ; } }

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