dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
class GFG { static String findMinLenStr ( String str , int k ) { int n = str . length ( ) ; int st = 0 ; int end = 0 ; int cnt [ ] = new int [ 26 ] ; for ( int i = 0 ; i < 26 ; i ++ ) cnt [ i ] = 0 ; int distEle = 0 ; int currlen ; int minlen = n ; int startInd = - 1 ; while ( end < n ) { cnt [ str . charAt ( end ) - ' a ' ] ++ ; if ( cnt [ str . charAt ( end ) - ' a ' ] == 1 ) distEle ++ ; if ( distEle > k ) { while ( st < end && distEle > k ) { if ( cnt [ str . charAt ( st ) - ' a ' ] == 1 ) distEle -- ; cnt [ str . charAt ( st ) - ' a ' ] -- ; st ++ ; } } if ( distEle == k ) { while ( st < end && cnt [ str . charAt ( st ) - ' a ' ] > 1 ) { cnt [ str . charAt ( st ) - ' a ' ] -- ; st ++ ; } currlen = end - st + 1 ; if ( currlen < minlen ) { minlen = currlen ; startInd = st ; } } end ++ ; } return str . substring ( startInd , startInd + minlen ) ; } public static void main ( String args [ ] ) { String str = " efecfefd " ; int k = 4 ; System . out . println ( findMinLenStr ( str , k ) ) ; } }

Index/key variables: i
Accumulator variables: distEle, end, i, st
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int minReplacement ( String s , int len ) { int ans = 0 ; for ( int i = 0 ; i < len ; i ++ ) { if ( i % 2 == 0 && s . charAt ( i ) == '1' ) ans ++ ; if ( i % 2 == 1 && s . charAt ( i ) == '0' ) ans ++ ; } return Math . min ( ans , len - ans ) ; } public static void main ( String args [ ] ) { String s = "1100" ; int len = s . length ( ) ; System . out . print ( minReplacement ( s , len ) ) ; } }

Accumulator variables: ans, i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int substrDeletion ( String str , int len ) { int count0 = 0 , count1 = 0 ; for ( int i = 0 ; i < len ; i ++ ) { if ( str . charAt ( i ) == '0' ) count0 ++ ; else count1 ++ ; } return Math . min ( count0 , count1 ) ; } public static void main ( String [ ] args ) { String str = "010" ; int len = str . length ( ) ; System . out . println ( substrDeletion ( str , len ) ) ; } }

Accumulator variables: count0, count1, i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static String groupCharacters ( char [ ] s , int len ) { String temp = " " ; for ( int i = 0 ; i < len ; i ++ ) if ( s [ i ] != ' ▁ ' ) temp = temp + s [ i ] ; len = temp . length ( ) ; String ans = " " ; int i = 0 ; while ( i < len ) { if ( temp . charAt ( i ) >= ( ' A ' ) && temp . charAt ( i ) <= ( ' Z ' ) ) { while ( i < len && temp . charAt ( i ) >= ( ' A ' ) && temp . charAt ( i ) <= ( ' Z ' ) ) { ans = ans + temp . charAt ( i ) ; i ++ ; } ans = ans + " ▁ " ; } else if ( temp . charAt ( i ) >= ( '0' ) && temp . charAt ( i ) <= ( '9' ) ) { while ( i < len && temp . charAt ( i ) >= ( '0' ) && temp . charAt ( i ) <= ( '9' ) ) { ans = ans + temp . charAt ( i ) ; i ++ ; } ans = ans + " ▁ " ; } else { while ( i < len && temp . charAt ( i ) >= ( ' * ' ) && temp . charAt ( i ) <= ( ' / ' ) ) { ans = ans + temp . charAt ( i ) ; i ++ ; } ans = ans + " ▁ " ; } } return ans ; } public static void main ( String [ ] args ) { String s = "34FTG234 + ▁ + - ▁ * " ; int len = s . length ( ) ; System . out . print ( groupCharacters ( s . toCharArray ( ) , len ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int Preprocess ( String A , String B ) { int n = A . length ( ) ; int ans = 0 ; for ( int i = 0 ; i < n / 2 ; i ++ ) { HashMap < Character , Integer > mp = new HashMap < > ( ) ; if ( mp . containsKey ( A . charAt ( i ) ) ) mp . put ( A . charAt ( i ) , mp . get ( A . charAt ( i ) ) + 1 ) ; else mp . put ( A . charAt ( i ) , 1 ) ; if ( mp . containsKey ( A . charAt ( n - i - 1 ) ) ) mp . put ( A . charAt ( n - i - 1 ) , mp . get ( A . charAt ( n - i - 1 ) ) + 1 ) ; else mp . put ( A . charAt ( n - i - 1 ) , 1 ) ; if ( mp . containsKey ( B . charAt ( i ) ) ) mp . put ( B . charAt ( i ) , mp . get ( B . charAt ( i ) ) + 1 ) ; else mp . put ( B . charAt ( i ) , 1 ) ; if ( mp . containsKey ( B . charAt ( n - i - 1 ) ) ) mp . put ( B . charAt ( n - i - 1 ) , mp . get ( B . charAt ( n - i - 1 ) ) + 1 ) ; else mp . put ( B . charAt ( n - i - 1 ) , 1 ) ; int sz = mp . size ( ) ; if ( sz == 4 ) ans += 2 ; else if ( sz == 3 ) ans += 1 + ( A . charAt ( i ) == A . charAt ( n - i - 1 ) ? 1 : 0 ) ; else if ( sz == 2 ) ans += mp . get ( A . charAt ( i ) ) != 2 ? 1 : 0 ; } if ( n % 2 == 1 && A . charAt ( n / 2 ) != B . charAt ( n / 2 ) ) ans ++ ; return ans ; } public static void main ( String [ ] args ) { String A = " abacaba " , B = " bacabaa " ; System . out . println ( Preprocess ( A , B ) ) ; } }

Accumulator variables: ans, i
Iterator variables: i
Class/struct names: GFG
Java program:
class GfG { static String leastLexiString ( String s ) { if ( s . length ( ) == 1 ) return s ; String x = leastLexiString ( s . substring ( 0 , s . length ( ) / 2 ) ) ; String y = leastLexiString ( s . substring ( s . length ( ) / 2 ) ) ; return String . valueOf ( ( x + y ) . compareTo ( y + x ) ) ; } static boolean areEquivalent ( String a , String b ) { return ! ( leastLexiString ( a ) . equals ( leastLexiString ( b ) ) ) ; } public static void main ( String [ ] args ) { String a = " aaba " ; String b = " abaa " ; if ( areEquivalent ( a , b ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; a = " aabb " ; b = " abab " ; if ( areEquivalent ( a , b ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } }

Class/struct names: GfG
Java program:
class GfG { static boolean isVowel ( char c ) { if ( c == ' a ' c == ' e ' c == ' i ' c == ' o ' c == ' u ' ) return true ; return false ; } static boolean checkPossibility ( String s1 , String s2 ) { int l1 = s1 . length ( ) ; int l2 = s2 . length ( ) ; if ( l1 != l2 ) return false ; for ( int i = 0 ; i < l1 ; i ++ ) { if ( isVowel ( s1 . charAt ( i ) ) && isVowel ( s2 . charAt ( i ) ) ) continue ; else if ( ! ( isVowel ( s1 . charAt ( i ) ) ) && ! ( isVowel ( s2 . charAt ( i ) ) ) ) continue ; else return false ; } return true ; } public static void main ( String [ ] args ) { String S1 = " abcgle " ; String S2 = " ezggli " ; if ( checkPossibility ( S1 , S2 ) == true ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GfG
Java program:
class GFG { static void generateString ( int A , int B ) { String rt = " " ; while ( 0 < A 0 < B ) { if ( A < B ) { if ( 0 < B -- ) { rt += ( ' b ' ) ; } if ( 0 < B -- ) { rt += ( ' b ' ) ; } if ( 0 < A -- ) { rt += ( ' a ' ) ; } } else if ( B < A ) { if ( 0 < A -- ) { rt += ( ' a ' ) ; } if ( 0 < A -- ) { rt += ( ' a ' ) ; } if ( 0 < B -- ) { rt += ( ' b ' ) ; } } else { if ( 0 < A -- ) { rt += ( ' a ' ) ; } if ( 0 < B -- ) { rt += ( ' b ' ) ; } } } System . out . println ( rt ) ; } public static void main ( String [ ] args ) { int A = 2 , B = 6 ; generateString ( A , B ) ; } }

Accumulator variables: A, B, rt
Class/struct names: GFG
Java program:
class GFG { static String getSubSeq ( String s , int n ) { String res = " " ; int cr = 0 ; while ( cr < n ) { char mx = s . charAt ( cr ) ; for ( int i = cr + 1 ; i < n ; i ++ ) { mx = ( char ) Math . max ( mx , s . charAt ( i ) ) ; } int lst = cr ; for ( int i = cr ; i < n ; i ++ ) { if ( s . charAt ( i ) == mx ) { res += s . charAt ( i ) ; lst = i ; } } cr = lst + 1 ; } return res ; } public static void main ( String [ ] args ) { String s = " geeksforgeeks " ; int n = s . length ( ) ; System . out . println ( getSubSeq ( s , n ) ) ; } }

Accumulator variables: i, res
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int countMinimalReplacements ( String s ) { int n = s . length ( ) ; int mini = Integer . MAX_VALUE ; char [ ] dup = "012" . toCharArray ( ) ; do { int dif = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( s . charAt ( i ) != dup [ i % 3 ] ) { dif ++ ; } } mini = Math . min ( mini , dif ) ; } while ( next_permutation ( dup ) ) ; return mini ; } static boolean next_permutation ( char [ ] p ) { for ( int a = p . length - 2 ; a >= 0 ; -- a ) { if ( p [ a ] < p [ a + 1 ] ) { for ( int b = p . length - 1 ; ; -- b ) { if ( p [ b ] > p [ a ] ) { char t = p [ a ] ; p [ a ] = p [ b ] ; p [ b ] = t ; for ( ++ a , b = p . length - 1 ; a < b ; ++ a , -- b ) { t = p [ a ] ; p [ a ] = p [ b ] ; p [ b ] = t ; } return true ; } } } } return false ; } public static void main ( String args [ ] ) { String s = "2101200" ; System . out . println ( countMinimalReplacements ( s ) ) ; } }

Index/key variables: a, b
Accumulator variables: dif, i
Iterator variables: a, b, i
Class/struct names: GFG
Java program:
class GFG { static int countSubStr ( String str , int len , int k ) { int count = 0 ; for ( int i = 0 ; i < len ; i ++ ) { int n = 0 ; for ( int j = i ; j < len ; j ++ ) { n = n * 10 + ( str . charAt ( j ) - '0' ) ; if ( n % k == 0 ) count ++ ; } } return count ; } public static void main ( String [ ] args ) { String str = "33445" ; int len = str . length ( ) ; int k = 11 ; System . out . println ( countSubStr ( str , len , k ) ) ; } }

Accumulator variables: count, i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
class GfG { static char Colour_Combination ( String s ) { char temp = s . charAt ( 0 ) ; for ( int i = 1 ; i < s . length ( ) ; i ++ ) { if ( temp != s . charAt ( i ) ) { if ( ( temp == ' B ' temp == ' G ' ) && ( s . charAt ( i ) == ' G ' || s . charAt ( i ) == ' B ' ) ) temp = ' Y ' ; else if ( ( temp == ' B ' temp == ' Y ' ) && ( s . charAt ( i ) == ' Y ' || s . charAt ( i ) == ' B ' ) ) temp = ' G ' ; else temp = ' B ' ; } } return temp ; } public static void main ( String [ ] args ) { String s = " GBYGB " ; System . out . println ( Colour_Combination ( s ) ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GfG
Java program:
class GfG { static void reverse ( String str , int x ) { int n = ( str . length ( ) - x ) / 2 ; for ( int i = 0 ; i < n ; i ++ ) System . out . print ( str . charAt ( i ) ) ; for ( int i = n + x - 1 ; i >= n ; i -- ) System . out . print ( str . charAt ( i ) ) ; for ( int i = n + x ; i < str . length ( ) ; i ++ ) System . out . print ( str . charAt ( i ) ) ; } public static void main ( String [ ] args ) { String str = " geeksforgeeks " ; int x = 3 ; reverse ( str , x ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GfG
Java program:
class GFG { static int getSteps ( String str , int i , int j , int n ) { int k = i + 1 ; int steps = 0 ; char ch = str . charAt ( i ) ; while ( k <= j ) { if ( str . charAt ( k ) != ch ) { steps ++ ; ch = str . charAt ( k ) ; } k ++ ; } return steps ; } static int getMinSteps ( String str , int i , int j , int n ) { if ( j < i ) { int temp = i ; i = j ; j = temp ; } int stepsToRight = getSteps ( str , i , j , n ) ; int stepsToLeft = getSteps ( str , 0 , i , n ) + getSteps ( str , j , n - 1 , n ) ; if ( str . charAt ( 0 ) != str . charAt ( n - 1 ) ) stepsToLeft ++ ; return Math . min ( stepsToLeft , stepsToRight ) ; } public static void main ( String [ ] args ) { String str = " SSNSS " ; int n = str . length ( ) ; int i = 0 , j = 3 ; System . out . println ( getMinSteps ( str , i , j , n ) ) ; } }

Accumulator variables: k, steps, stepsToLeft
Class/struct names: GFG
Java program:
import java . util . ArrayList ; public class GFG { static void printArrayList ( ArrayList < String > arrL ) { arrL . remove ( " " ) ; for ( int i = 0 ; i < arrL . size ( ) ; i ++ ) System . out . print ( arrL . get ( i ) + " ▁ " ) ; } public static ArrayList < String > getPermutation ( String str ) { if ( str . length ( ) == 0 ) { ArrayList < String > empty = new ArrayList < > ( ) ; empty . add ( " " ) ; return empty ; } char ch = str . charAt ( 0 ) ; String subStr = str . substring ( 1 ) ; ArrayList < String > prevResult = getPermutation ( subStr ) ; ArrayList < String > Res = new ArrayList < > ( ) ; for ( String val : prevResult ) { for ( int i = 0 ; i <= val . length ( ) ; i ++ ) { Res . add ( val . substring ( 0 , i ) + ch + val . substring ( i ) ) ; } } return Res ; } public static void main ( String [ ] args ) { String str = " abc " ; printArrayList ( getPermutation ( str ) ) ; } }

Accumulator variables: i
Iterator variables: i, val
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int MAX_CHAR = 256 ; static int countSubStrings ( String s , String anotherStr , int k ) { boolean illegal [ ] = new boolean [ MAX_CHAR ] ; for ( int i = 0 ; i < anotherStr . length ( ) ; i ++ ) { illegal [ anotherStr . charAt ( i ) ] = true ; } HashSet < String > us = new HashSet < String > ( ) ; for ( int i = 0 ; i < s . length ( ) ; ++ i ) { String ss = " " ; int count = 0 ; for ( int j = i ; j < s . length ( ) ; ++ j ) { if ( illegal [ s . charAt ( j ) ] ) { ++ count ; } ss = ss + s . charAt ( j ) ; if ( count <= k ) { us . add ( ss ) ; } else { break ; } } } return us . size ( ) ; } public static void main ( String [ ] args ) { String str = " acbacbacaa " ; String anotherStr = " abcdefghijklmnopqrstuvwxyz " ; int k = 2 ; System . out . println ( countSubStrings ( str , anotherStr , k ) ) ; } }

Index/key variables: MAX_CHAR
Accumulator variables: i
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . HashMap ; class GFG { static int countPairs ( String [ ] bracks , int num ) { HashMap < Integer , Integer > open = new HashMap < > ( ) ; HashMap < Integer , Integer > close = new HashMap < > ( ) ; int cnt = 0 ; for ( int i = 0 ; i < num ; i ++ ) { String s = bracks [ i ] ; int l = s . length ( ) ; int op = 0 , cl = 0 ; for ( int j = 0 ; j < l ; j ++ ) { if ( s . charAt ( j ) == ' ( ' ) op ++ ; else { if ( op != 0 ) op -- ; else cl ++ ; } } if ( op != 0 && cl == 0 ) open . put ( op , open . get ( op ) == null ? 1 : open . get ( op ) + 1 ) ; if ( cl != 0 && op == 0 ) close . put ( cl , close . get ( cl ) == null ? 1 : close . get ( cl ) + 1 ) ; if ( op == 0 && cl == 0 ) cnt ++ ; } cnt /= 2 ; for ( HashMap . Entry < Integer , Integer > it : open . entrySet ( ) ) cnt += Math . min ( it . getValue ( ) , close . get ( it . getKey ( ) ) ) ; return cnt ; } public static void main ( String [ ] args ) { String [ ] bracks = { " ) ( ) ) " , " ) " , " ( ( " , " ( ( " , " ( " , " ) " , " ) " } ; int num = bracks . length ; System . out . println ( countPairs ( bracks , num ) ) ; } }

Index/key variables: i
Accumulator variables: cl, cnt, i, j, op
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { public static String decrypt ( String s , int l ) { String ans = " " ; if ( l % 2 == 1 ) { int cnt = 0 ; int indl = 0 , indr = l - 1 ; while ( ans . length ( ) != l ) { if ( cnt % 2 == 0 ) ans += s . charAt ( indl ++ ) ; else ans += s . charAt ( indr -- ) ; cnt ++ ; } } else { int cnt = 0 ; int indl = 0 , indr = l - 1 ; while ( ans . length ( ) != l ) { if ( cnt % 2 == 0 ) ans += s . charAt ( indr -- ) ; else ans += s . charAt ( indl ++ ) ; cnt ++ ; } } StringBuffer sbr = new StringBuffer ( ans ) ; sbr . reverse ( ) ; return sbr . toString ( ) ; } public static void main ( String [ ] args ) { String s = " segosegekfrek " ; int l = s . length ( ) ; System . out . println ( decrypt ( s , l ) ) ; } }

Accumulator variables: ans, cnt, indl, indr
Class/struct names: GFG
Java program:
class GFG { static String removeChars ( String s ) { String modifiedStr = " " ; modifiedStr += s . charAt ( 0 ) ; for ( int i = 1 ; i < s . length ( ) ; i ++ ) { if ( Character . isUpperCase ( s . charAt ( i ) ) && Character . isLowerCase ( s . charAt ( i - 1 ) ) || Character . isLowerCase ( s . charAt ( i ) ) && Character . isUpperCase ( s . charAt ( i - 1 ) ) ) modifiedStr += s . charAt ( i ) ; } return modifiedStr ; } public static void main ( String [ ] args ) { String s = " GeeksForGeeks " ; System . out . println ( removeChars ( s ) ) ; } }

Accumulator variables: i, modifiedStr
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int pangramCost ( int arr [ ] , String str ) { int cost = 0 ; boolean [ ] occurred = new boolean [ 26 ] ; for ( int i = 0 ; i < 26 ; i ++ ) occurred [ i ] = false ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) occurred [ str . charAt ( i ) - ' a ' ] = true ; for ( int i = 0 ; i < 26 ; i ++ ) { if ( occurred [ i ] == false ) cost += arr [ i ] ; } return cost ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 , 16 , 17 , 18 , 19 , 20 , 21 , 22 , 23 , 24 , 25 , 26 } ; String str = " abcdefghijklmopqrstuvwz " ; System . out . println ( pangramCost ( arr , str ) ) ; } }

Index/key variables: i
Accumulator variables: cost, i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static String output = " " ; static void pairStar ( String input , int i ) { output = output + input . charAt ( i ) ; if ( i == input . length ( ) - 1 ) return ; if ( input . charAt ( i ) == input . charAt ( i + 1 ) ) output = output + ' * ' ; pairStar ( input , i + 1 ) ; } public static void main ( String [ ] args ) { String input = " geeks " ; pairStar ( input , 0 ) ; System . out . println ( output ) ; } }

Class/struct names: GFG
Java program:
class GFG { static int maxOperations ( String str ) { int i , g , gk , gks ; i = g = gk = gks = 0 ; for ( i = 0 ; i < str . length ( ) ; i ++ ) { if ( str . charAt ( i ) == ' g ' ) { g ++ ; } else if ( str . charAt ( i ) == ' k ' ) { if ( g > 0 ) { g -- ; gk ++ ; } } else if ( str . charAt ( i ) == ' s ' ) { if ( gk > 0 ) { gk -- ; gks ++ ; } } } return gks ; } public static void main ( String args [ ] ) { String a = " ggkssk " ; System . out . print ( maxOperations ( a ) ) ; } }

Accumulator variables: g, gk, gks, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; public class GFG { static int [ ] getFrequencies ( String str ) { int freq [ ] = new int [ 26 ] ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { freq [ str . charAt ( i ) - ' a ' ] ++ ; } return freq ; } static int countMinParts ( String str ) { int n = str . length ( ) ; int freq [ ] = getFrequencies ( str ) ; List < Integer > oddFreq = new ArrayList < > ( ) ; List < Integer > evenFreq = new ArrayList < > ( ) ; int i , sumEven = 0 ; for ( i = 0 ; i < 26 ; i ++ ) { if ( freq [ i ] == 0 ) continue ; if ( freq [ i ] % 2 == 0 ) evenFreq . add ( freq [ i ] ) ; else oddFreq . add ( freq [ i ] ) ; } for ( i = 0 ; i < evenFreq . size ( ) ; i ++ ) { sumEven += evenFreq . get ( i ) ; } if ( oddFreq . size ( ) == 0 ) return 1 ; if ( sumEven == 0 ) { if ( oddFreq . size ( ) == 1 ) return 1 ; return 0 ; } i = 0 ; while ( i < oddFreq . size ( ) ) { if ( ( sumEven / 2 ) % oddFreq . size ( ) == 0 ) return oddFreq . size ( ) ; if ( oddFreq . get ( i ) == 1 ) { i ++ ; continue ; } sumEven += 2 ; oddFreq . set ( i , oddFreq . get ( i ) - 2 ) ; } return n ; } public static void main ( String [ ] args ) { String s = " noonpeep " ; System . out . println ( countMinParts ( s ) ) ; } }

Index/key variables: i
Accumulator variables: i, sumEven
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static void printPattern ( char [ ] s , int n ) { System . out . println ( s ) ; int i = 0 , j = n - 1 ; while ( i < j ) { char c = s [ i ] ; s [ i ] = s [ j ] ; s [ j ] = c ; i ++ ; j -- ; } i = 0 ; j = n - 1 ; while ( j - i > 1 ) { s [ i ] = s [ j ] = ' * ' ; System . out . println ( s ) ; i ++ ; j -- ; } } public static void main ( String [ ] args ) { char [ ] s = " geeks " . toCharArray ( ) ; int n = s . length ; printPattern ( s , n ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static boolean prime ( int n ) { if ( n <= 1 ) { return false ; } if ( n <= 3 ) { return true ; } if ( n % 2 == 0 n % 3 == 0 ) { return false ; } for ( int i = 5 ; i * i <= n ; i = i + 6 ) { if ( n % i == 0 || n % ( i + 2 ) == 0 ) { return false ; } } return true ; } static boolean isVowel ( char c ) { c = Character . toLowerCase ( c ) ; if ( c == ' a ' c == ' e ' c == ' i ' c == ' o ' c == ' u ' ) { return true ; } return false ; } static boolean isValidString ( String word ) { int cnt = 0 ; for ( int i = 0 ; i < word . length ( ) ; i ++ ) { if ( isVowel ( word . charAt ( i ) ) ) { cnt ++ ; } } if ( prime ( cnt ) ) { return true ; } else { return false ; } } public static void main ( String args [ ] ) { String s = " geeksforgeeks " ; if ( isValidString ( s ) ) System . out . println ( " YES " ) ; else System . out . println ( " NO " ) ; } }

Accumulator variables: cnt, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class solution { static void printExpansion ( String str ) { String suff = " " ; for ( int i = str . length ( ) - 1 ; i >= 0 ; i -- ) { suff = suff + str . charAt ( i ) ; System . out . print ( suff ) ; } } public static void main ( String args [ ] ) { String str = " geeks " ; printExpansion ( str ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: solution
Java program:
import java . util . * ; class GFG { static char logicalExpressionEvaluation ( String str ) { Stack < Character > arr = new Stack < Character > ( ) ; for ( int i = str . length ( ) - 1 ; i >= 0 ; i -- ) { if ( str . charAt ( i ) == ' [ ' ) { Vector < Character > s = new Stack < Character > ( ) ; while ( arr . peek ( ) != ' ] ' ) { s . add ( arr . peek ( ) ) ; arr . pop ( ) ; } arr . pop ( ) ; if ( s . size ( ) == 3 ) { arr . push ( s . get ( 2 ) == '1' ? '0' : '1' ) ; } else if ( s . size ( ) == 5 ) { int a = s . get ( 0 ) - 48 , b = s . get ( 4 ) - 48 , c ; if ( s . get ( 2 ) == ' & ' ) { c = a & b ; } else { c = a | b ; } arr . push ( ( char ) ( c + 48 ) ) ; } } else { arr . push ( str . charAt ( i ) ) ; } } return arr . peek ( ) ; } public static void main ( String [ ] args ) { String str = " [ | , [ & ,1 , [ ! , 0 ] ] , [ ! , [ | , [ ▁ , 1,0 ] , [ ! ,1 ] ] ] ] " ; System . out . println ( logicalExpressionEvaluation ( str ) ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
public class GFG { static int count ( String s , int k ) { int n = s . length ( ) ; int d = 0 , i ; int count = 0 ; for ( i = 0 ; i < n ; i ++ ) d += s . charAt ( i ) ; if ( d % k == 0 ) count += 1 ; for ( i = k ; i < n ; i ++ ) { int prev = s . charAt ( i - k ) ; d -= prev ; d += s . charAt ( i ) ; if ( d % k == 0 ) count += 1 ; } return count ; } public static void main ( String [ ] args ) { String s = " bcgabc " ; int k = 3 ; int ans = count ( s , k ) ; System . out . println ( ans ) ; } }

Accumulator variables: count, d, i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static String printFinalString ( String s ) { int i , n ; n = s . length ( ) ; int x = 0 , y = 0 ; for ( i = 0 ; i < n ; i ++ ) { if ( s . charAt ( i ) == ' x ' ) { x ++ ; else { y ++ ; } } String finalString = " " ; if ( x > y ) { for ( i = 0 ; i < x - y ; i ++ ) { finalString += " x " ; } } else { for ( i = 0 ; i < y - x ; i ++ ) { finalString += " y " ; } } return finalString ; } public static void main ( String args [ ] ) { String s = " xxyyxyy " ; System . out . println ( printFinalString ( s ) ) ; } }

Accumulator variables: finalString, i, x, y
Iterator variables: i
Class/struct names: GFG
Java program:
class GfG { static String K_String ( String s , int k ) { int n = s . length ( ) ; int fre [ ] = new int [ 26 ] ; for ( int i = 0 ; i < n ; i ++ ) fre [ s . charAt ( i ) - ' a ' ] ++ ; String str = " " ; for ( int i = 0 ; i < 26 ; i ++ ) { if ( fre [ i ] % k == 0 ) { int x = fre [ i ] / k ; while ( x != 0 ) { str += ( char ) ( i + ' a ' ) ; x -- ; } } else { return " - 1" ; } } return str ; } public static void main ( String [ ] args ) { String s = " aabb " ; int k = 2 ; System . out . println ( K_String ( s , k ) ) ; } }

Index/key variables: i
Accumulator variables: i, str, x
Iterator variables: i
Class/struct names: GfG