dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
class GFG { static int MAX = 26 ; static void compressString ( String s , int n ) { int freq [ ] = new int [ MAX ] ; for ( int i = 0 ; i < n ; i ++ ) { freq [ s . charAt ( i ) - ' a ' ] ++ ; } for ( int i = 0 ; i < MAX ; i ++ ) { if ( freq [ i ] == 0 ) continue ; System . out . print ( ( char ) ( i + ' a ' ) + " " + freq [ i ] ) ; } } public static void main ( String [ ] args ) { String s = " geeksforgeeks " ; int n = s . length ( ) ; compressString ( s , n ) ; } }

Index/key variables: MAX, i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static void decBinary ( int arr [ ] , int n ) { int k = ( int ) ( Math . log ( n ) / Math . log ( 2 ) ) ; while ( n > 0 ) { arr [ k -- ] = n % 2 ; n /= 2 ; } } static int binaryDec ( int arr [ ] , int n ) { int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) ans += arr [ i ] << ( n - i - 1 ) ; return ans ; } static int concat ( int m , int n ) { int k = ( int ) ( Math . log ( m ) / Math . log ( 2 ) ) + 1 ; int l = ( int ) ( Math . log ( n ) / Math . log ( 2 ) ) + 1 ; int a [ ] = new int [ k ] ; int b [ ] = new int [ l ] ; int c [ ] = new int [ k + l ] ; decBinary ( a , m ) ; decBinary ( b , n ) ; int in = 0 ; for ( int i = 0 ; i < k ; i ++ ) c [ in ++ ] = a [ i ] ; for ( int i = 0 ; i < l ; i ++ ) c [ in ++ ] = b [ i ] ; return ( binaryDec ( c , k + l ) ) ; } public static void main ( String [ ] args ) { int m = 4 , n = 5 ; System . out . println ( concat ( m , n ) ) ; } }

Index/key variables: i, k, l
Accumulator variables: ans, i, in, k, n
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { public static int getBinaryLength ( int n ) { int length = 0 ; while ( n > 0 ) { length += 1 ; n /= 2 ; } return length ; } public static int concat ( int m , int n ) { int length = getBinaryLength ( n ) ; return ( m << length ) + n ; } public static void main ( String [ ] args ) throws Exception { int m = 4 , n = 5 ; System . out . println ( concat ( m , n ) ) ; } }

Accumulator variables: length, n
Class/struct names: GFG
Java program:
class GFG { static String addZeros ( String str , int n ) { for ( int i = 0 ; i < n ; i ++ ) { str = "0" + str ; } return str ; } static String getXOR ( String a , String b ) { int aLen = a . length ( ) ; int bLen = b . length ( ) ; if ( aLen > bLen ) { a = addZeros ( b , aLen - bLen ) ; } else if ( bLen > aLen ) { a = addZeros ( a , bLen - aLen ) ; } int len = Math . max ( aLen , bLen ) ; String res = " " ; for ( int i = 0 ; i < len ; i ++ ) { if ( a . charAt ( i ) == b . charAt ( i ) ) res += "0" ; else res += "1" ; } return res ; } public static void main ( String [ ] args ) { String a = "11001" , b = "111111" ; System . out . println ( getXOR ( a , b ) ) ; } }

Accumulator variables: i, res
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class Node { int soln [ ] ; int level ; ArrayList < Node > child ; Node parent ; Node ( Node parent , int level , int N ) { this . parent = parent ; this . level = level ; this . soln = new int [ N ] ; } } class GFG { static int N ; public static Queue < Node > Q ; public static void generate ( Node n ) { if ( n . level == N ) { for ( int i = 0 ; i <= N - 1 ; i ++ ) { System . out . print ( n . soln [ i ] ) ; } System . out . println ( ) ; } else { n . child = new ArrayList < Node > ( ) ; int l = n . level ; for ( int i = 0 ; i <= 1 ; i ++ ) { Node x = new Node ( n , l + 1 , N ) ; for ( int k = 0 ; k < l ; k ++ ) { x . soln [ k ] = n . soln [ k ] ; } x . soln [ l ] = i ; n . child . add ( x ) ; Q . add ( x ) ; } } } public static void main ( String args [ ] ) { N = 3 ; Node root = new Node ( null , 0 , N ) ; Q = new LinkedList < Node > ( ) ; Q . add ( root ) ; while ( Q . size ( ) != 0 ) { Node E = Q . poll ( ) ; generate ( E ) ; } } }

Index/key variables: N, i, k, l
Accumulator variables: i, k
Iterator variables: i, k
Class/struct names: GFG, Node
Java program:
class GFG { final static int MAX = 26 ; static int minOperation ( String str , int len ) { int first [ ] = new int [ MAX ] ; int last [ ] = new int [ MAX ] ; for ( int i = 0 ; i < MAX ; i ++ ) { first [ i ] = - 1 ; last [ i ] = - 1 ; } for ( int i = 0 ; i < len ; i ++ ) { int index = ( str . charAt ( i ) - ' a ' ) ; if ( first [ index ] == - 1 ) first [ index ] = i ; last [ index ] = i ; } int minOp = - 1 ; for ( int i = 0 ; i < MAX ; i ++ ) { if ( first [ i ] == - 1 first [ i ] == last [ i ] ) continue ; int cnt = len - ( last [ i ] - first [ i ] + 1 ) ; if ( minOp == - 1 cnt < minOp ) minOp = cnt ; } return minOp ; } public static void main ( String [ ] args ) { String str = " abcda " ; int len = str . length ( ) ; System . out . println ( minOperation ( str , len ) ) ; } }

Index/key variables: MAX, i, index
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int N = 2 ; static boolean isVowel ( char ch ) { return ( ch == ' a ' ch == ' e ' ch == ' i ' ch == ' o ' ch == ' u ' ) ; } static int countVowels ( String str , int l , int r ) { int cnt = 0 ; for ( int i = l ; i <= r ; i ++ ) { if ( isVowel ( str . charAt ( i ) ) ) cnt ++ ; } return cnt ; } static void performQueries ( String str , int queries [ ] [ ] , int q ) { for ( int i = 0 ; i < q ; i ++ ) { System . out . println ( countVowels ( str , queries [ i ] [ 0 ] , queries [ i ] [ 1 ] ) ) ; } } public static void main ( String [ ] args ) { String str = " geeksforgeeks " ; int queries [ ] [ ] = { { 1 , 3 } , { 2 , 4 } , { 1 , 9 } } ; int q = queries . length ; performQueries ( str , queries , q ) ; } }

Index/key variables: i
Accumulator variables: cnt, i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static class node { char data ; node next ; } ; static node add ( char data ) { node newnode = new node ( ) ; newnode . data = data ; newnode . next = null ; return newnode ; } static node string_to_SLL ( String text , node head ) { head = add ( text . charAt ( 0 ) ) ; node curr = head ; for ( int i = 1 ; i < text . length ( ) ; i ++ ) { curr . next = add ( text . charAt ( i ) ) ; curr = curr . next ; } return head ; } static void print ( node head ) { node curr = head ; while ( curr != null ) { System . out . print ( curr . data + " ▁ - > ▁ " ) ; curr = curr . next ; } } public static void main ( String [ ] args ) { String text = " GEEKS " ; node head = null ; head = string_to_SLL ( text , head ) ; print ( head ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG, node
Java program:
import java . util . * ; class GFG { static int minLength ( String str , int len ) { Stack < Character > s = new Stack < Character > ( ) ; for ( int i = 0 ; i < len ; i ++ ) { if ( s . empty ( ) ) { s . push ( str . charAt ( i ) ) ; } else { char c = s . peek ( ) ; if ( c != str . charAt ( i ) && Character . toUpperCase ( c ) == Character . toUpperCase ( ( str . charAt ( i ) ) ) ) { s . pop ( ) ; } else { s . push ( str . charAt ( i ) ) ; } } } return s . size ( ) ; } public static void main ( String [ ] args ) { String str = " ASbBsd " ; int len = str . length ( ) ; System . out . println ( minLength ( str , len ) ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int MAX = 26 ; static boolean canBeMadeEqual ( String str1 , String str2 ) { int len1 = str1 . length ( ) ; int len2 = str2 . length ( ) ; if ( len1 == len2 ) { int freq [ ] = new int [ MAX ] ; for ( int i = 0 ; i < len1 ; i ++ ) { freq [ str1 . charAt ( i ) - ' a ' ] ++ ; } for ( int i = 0 ; i < len2 ; i ++ ) { if ( freq [ str2 . charAt ( i ) - ' a ' ] > 0 ) return true ; } } return false ; } public static void main ( String [ ] args ) { String str1 = " abc " , str2 = " defa " ; if ( canBeMadeEqual ( str1 , str2 ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } }

Index/key variables: MAX
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int getCount ( char [ ] str , int n ) { int cnt = 0 ; int i = 0 ; while ( i < n - 2 ) { if ( str [ i ] == str [ i + 1 ] && str [ i ] == str [ i + 2 ] ) { cnt ++ ; i = i + 2 ; } else { i ++ ; } } return cnt ; } static public void main ( String [ ] arg ) { String str = " aabbbcc " ; int n = str . length ( ) ; System . out . println ( getCount ( str . toCharArray ( ) , n ) ) ; } }

Index/key variables: i
Accumulator variables: cnt, i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int fact ( int n ) { int fact = 1 ; for ( int i = 1 ; i <= n ; i ++ ) fact *= i ; return fact ; } static int countStrings ( String str , int n ) { Set < Character > distinct_char = new HashSet < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { distinct_char . add ( str . charAt ( i ) ) ; } return fact ( distinct_char . size ( ) ) ; } public static void main ( String [ ] args ) { String str = " geeksforgeeks " ; int n = str . length ( ) ; System . out . println ( countStrings ( str , n ) ) ; } }

Accumulator variables: fact, i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static char getChar ( String str ) { int sum = 0 ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { sum += ( str . charAt ( i ) - ' a ' + 1 ) ; } if ( sum % 26 == 0 ) return ' z ' ; else { sum = sum % 26 ; return ( char ) ( ' a ' + sum - 1 ) ; } } public static void main ( String [ ] args ) { String str = " gfg " ; System . out . println ( getChar ( str ) ) ; } }

Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static String reverse ( char [ ] str , int len , int l , int r ) { if ( l < 0 r >= len l > r ) return " Invalid ▁ range ! " ; while ( l < r ) { char c = str [ l ] ; str [ l ] = str [ r ] ; str [ r ] = c ; l ++ ; r -- ; } String string = new String ( str ) ; return string ; } public static void main ( String [ ] args ) { String str = " geeksforgeeks " ; int len = str . length ( ) ; int l = 5 , r = 7 ; System . out . println ( reverse ( str . toCharArray ( ) , len , l , r ) ) ; } }

Index/key variables: l, r
Accumulator variables: l, r
Class/struct names: GFG
Java program:
class GFG { static void encrypt ( char input [ ] ) { char evenPos = ' @ ' , oddPos = ' ! ' ; int repeat , ascii ; for ( int i = 0 ; i < input . length ; i ++ ) { ascii = input [ i ] ; repeat = ascii >= 97 ? ascii - 96 : ascii - 64 ; for ( int j = 0 ; j < repeat ; j ++ ) { if ( i % 2 == 0 ) System . out . printf ( " % c " , oddPos ) ; else System . out . printf ( " % c " , evenPos ) ; } } } public static void main ( String [ ] args ) { char input [ ] = { ' A ' , ' b ' , ' C ' , ' d ' } ; encrypt ( input ) ; } }

Index/key variables: i
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
class GFG { static boolean IsRedundantBraces ( String A ) { int a = 0 , b = 0 ; for ( int i = 0 ; i < A . length ( ) ; i ++ ) { if ( A . charAt ( i ) == ' ( ' && A . charAt ( i + 2 ) == ' ) ' ) return true ; if ( A . charAt ( i ) == ' * ' || A . charAt ( i ) == ' + ' || A . charAt ( i ) == ' - ' || A . charAt ( i ) == ' / ' ) a ++ ; if ( A . charAt ( i ) == ' ( ' ) b ++ ; } if ( b > a ) return true ; return false ; } public static void main ( String [ ] args ) { String A = " ( ( ( a + b ) ▁ + ▁ c ) ▁ + ▁ d ) " ; if ( IsRedundantBraces ( A ) ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } }

Accumulator variables: a, b, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static String balancedBrackets ( String str ) { int dep = 0 ; int minDep = 0 ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { if ( str . charAt ( i ) == ' ( ' ) dep ++ ; else dep -- ; if ( minDep > dep ) minDep = dep ; } if ( minDep < 0 ) { for ( int i = 0 ; i < Math . abs ( minDep ) ; i ++ ) str = ' ( ' + str ; } dep = 0 ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { if ( str . charAt ( i ) == ' ( ' ) dep ++ ; else dep -- ; } if ( dep != 0 ) { for ( int i = 0 ; i < dep ; i ++ ) str = str + ' ) ' ; } return str ; } public static void main ( String [ ] args ) { String str = " ) ) ) ( ) " ; System . out . println ( balancedBrackets ( str ) ) ; } }

Accumulator variables: dep, i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int minOperations ( String str , int n ) { int count = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( str . charAt ( i ) != str . charAt ( i + 1 ) ) count ++ ; } return ( count + 1 ) / 2 ; } public static void main ( String [ ] args ) { String str = "000111" ; int n = str . length ( ) ; System . out . println ( minOperations ( str , n ) ) ; } }

Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int find_digit ( String s , int n ) { int first_digit = - 1 ; for ( int i = n - 1 ; i >= 0 ; i -- ) { if ( s . charAt ( i ) < '0' || s . charAt ( i ) > '9' ) { first_digit = i ; break ; } } first_digit ++ ; int s_len = first_digit ; int num = 0 , pw = 1 ; int i = n - 1 ; while ( i >= 0 ) { if ( s . charAt ( i ) >= '0' && s . charAt ( i ) <= '9' ) { int digit = s . charAt ( i ) - '0' ; num = num + ( pw * digit ) ; if ( num >= s_len ) return - 1 ; pw = pw * 10 ; } i -- ; } num = num * 10 ; int req = s_len - num ; if ( req > 9 req < 0 ) return - 1 ; return req ; } public static void main ( String [ ] args ) { String s = " abcd0" ; int n = s . length ( ) ; System . out . print ( find_digit ( s , n ) ) ; } }

Accumulator variables: first_digit, i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static boolean canConvert ( String str1 , String str2 ) { int i = 0 , j = 0 ; while ( i < str1 . length ( ) && j < str2 . length ( ) ) { if ( str1 . charAt ( i ) != str2 . charAt ( j ) ) { if ( str1 . charAt ( i ) == '0' && str2 . charAt ( j ) == '1' && i + 1 < str1 . length ( ) && str1 . charAt ( i + 1 ) == '0' ) { i += 2 ; j ++ ; } else { return false ; } } else { i ++ ; j ++ ; } } if ( i == str1 . length ( ) && j == str2 . length ( ) ) return true ; return false ; } public static void main ( String [ ] args ) { String str1 = "00100" , str2 = "111" ; if ( canConvert ( str1 , str2 ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } }

Accumulator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void reverse ( String s ) { Stack < String > stc = new Stack < > ( ) ; String temp = " " ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == ' ▁ ' ) { stc . add ( temp ) ; temp = " " ; } else { temp = temp + s . charAt ( i ) ; } } stc . add ( temp ) ; while ( ! stc . isEmpty ( ) ) { temp = stc . peek ( ) ; System . out . print ( temp + " ▁ " ) ; stc . pop ( ) ; } System . out . println ( ) ; } public static void main ( String [ ] args ) { String s = " I ▁ Love ▁ To ▁ Code " ; reverse ( s ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static void printMatrix ( int n , int m ) { if ( n < 5 m < 5 ) { System . out . print ( - 1 ) ; return ; } char [ ] s = " aeiou " . toCharArray ( ) ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { System . out . print ( s [ j % 5 ] + " ▁ " ) ; } System . out . println ( ) ; char c = s [ 0 ] ; for ( int k = 0 ; k < 4 ; k ++ ) { s [ k ] = s [ k + 1 ] ; } s [ 4 ] = c ; } } public static void main ( String [ ] args ) { int n = 5 , m = 5 ; printMatrix ( n , m ) ; } }

Index/key variables: k
Accumulator variables: i, j, k
Iterator variables: i, j, k
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static boolean isTwoAlter ( String s ) { for ( int i = 0 ; i < s . length ( ) - 2 ; i ++ ) { if ( s . charAt ( i ) != s . charAt ( i + 2 ) ) { return false ; } } if ( s . charAt ( 0 ) == s . charAt ( 1 ) ) return false ; return true ; } public static void main ( String [ ] args ) { String str = " ABAB " ; if ( isTwoAlter ( str ) ) System . out . print ( " Yes " ) ; else System . out . print ( " No " ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int minOperations ( int n , String a , String b , String c ) { int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { char x = a . charAt ( i ) ; char y = b . charAt ( i ) ; char z = c . charAt ( i ) ; if ( x == y && y == z ) ; else if ( x == y y == z x == z ) { ans ++ ; } else { ans += 2 ; } } return ans ; } public static void main ( String [ ] args ) { String a = " place " ; String b = " abcde " ; String c = " plybe " ; int n = a . length ( ) ; System . out . print ( minOperations ( n , a , b , c ) ) ; } }

Accumulator variables: ans, i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static boolean check ( String s ) { int n = s . length ( ) ; for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( s . charAt ( i ) > s . charAt ( i + 1 ) ) return true ; } return false ; } public static void main ( String args [ ] ) { String s = " geeksforgeeks " ; if ( check ( s ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int countSubStr ( String str , int n , char x ) { int res = 0 , count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( str . charAt ( i ) == x ) { res += ( ( count + 1 ) * ( n - i ) ) ; count = 0 ; } else count ++ ; } return res ; } public static void main ( String [ ] args ) { String str = " abcabc " ; int n = str . length ( ) ; char x = ' c ' ; System . out . println ( countSubStr ( str , n , x ) ) ; } }

Accumulator variables: count, i, res
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int countSubStr ( String str , int n ) { int len = str . length ( ) ; return ( len - n + 1 ) ; } public static void main ( String args [ ] ) { String str = " geeksforgeeks " ; int n = 5 ; System . out . print ( countSubStr ( str , n ) ) ; } }

Class/struct names: GFG
Java program:
class GFG { static int countSubstrings ( String s , char c ) { int n = s . length ( ) ; int cnt = 0 ; int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( s . charAt ( i ) != c ) cnt ++ ; else { sum += ( cnt * ( cnt + 1 ) ) / 2 ; cnt = 0 ; } } sum += ( cnt * ( cnt + 1 ) ) / 2 ; return sum ; } public static void main ( String [ ] args ) { String s = " baa " ; char c = ' b ' ; System . out . println ( countSubstrings ( s , c ) ) ; } }

Accumulator variables: cnt, i, sum
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . Arrays ; import java . lang . Math ; class GfG { static int getMinimizedSum ( String str , int len ) { int i , maxVal = Integer . MIN_VALUE , sum = 0 ; int occurrences [ ] = new int [ 26 ] ; Arrays . fill ( occurrences , 0 ) ; for ( i = 0 ; i < len ; i ++ ) { occurrences [ str . charAt ( i ) - ' a ' ] ++ ; sum += ( int ) str . charAt ( i ) ; } for ( i = 0 ; i < 26 ; i ++ ) maxVal = Math . max ( maxVal , occurrences [ i ] * ( i + ' a ' ) ) ; return ( sum - maxVal ) ; } public static void main ( String [ ] args ) { String str = " geeksforgeeks " ; int len = str . length ( ) ; System . out . println ( getMinimizedSum ( str , len ) ) ; } }

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GfG
Java program:
class GFG { static boolean isPalindrome ( String s ) { int i = 0 ; int j = s . length ( ) - 1 ; while ( i < j ) { if ( s . charAt ( i ) != s . charAt ( j ) ) return false ; i ++ ; j -- ; } return true ; } static int getIndex ( String S1 , String S2 , int n ) { String S = " " ; for ( int i = 0 ; i < n ; i ++ ) { S = S + S1 . charAt ( i ) ; String Temp = " " ; for ( int j = i + 1 ; j < n ; j ++ ) Temp += S2 . charAt ( j ) ; if ( isPalindrome ( S + Temp ) ) { return i ; } } return - 1 ; } public static void main ( String [ ] args ) { String S1 = " abcdf " , S2 = " sfgba " ; int n = S1 . length ( ) ; System . out . println ( getIndex ( S1 , S2 , n ) ) ; } }

Accumulator variables: Temp, i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
class GFG { static boolean isPalindrome ( String s , int i , int j ) { while ( i < j ) { if ( s . charAt ( i ) != s . charAt ( j ) ) return false ; i ++ ; j -- ; } return true ; } static int getIndex ( String s1 , String s2 , int len ) { int i = 0 , j = len - 1 ; while ( i < j ) { if ( s1 . charAt ( i ) != s2 . charAt ( j ) ) { break ; } i ++ ; j -- ; } if ( i == j ) { return i - 1 ; } else if ( isPalindrome ( s2 , i , j ) ) return i - 1 ; else if ( isPalindrome ( s1 , i , j ) ) return j ; return - 1 ; } public static void main ( String args [ ] ) { String s1 = " abcdf " , s2 = " sfgba " ; int len = s1 . length ( ) ; System . out . println ( getIndex ( s1 , s2 , len ) ) ; } }

Accumulator variables: i, j
Class/struct names: GFG
Java program:
class GFG { static int count_acronym ( int n , String [ ] arr ) { int [ ] freq = new int [ 26 ] ; for ( int i = 0 ; i < n ; i ++ ) freq [ arr [ i ] . charAt ( 0 ) - ' a ' ] ++ ; int cnt = 0 ; for ( int i = 0 ; i < n ; i ++ ) { String st = arr [ i ] ; int [ ] num = new int [ 26 ] ; for ( int j = 0 ; j < st . length ( ) ; j ++ ) num [ st . charAt ( j ) - ' a ' ] ++ ; boolean flag = true ; for ( int j = 1 ; j < 26 ; j ++ ) { if ( num [ j ] > freq [ j ] ) { flag = false ; break ; } } int x = st . charAt ( 0 ) - ' a ' ; if ( freq [ x ] - 1 < num [ x ] ) flag = false ; if ( flag ) cnt ++ ; } return cnt ; } public static void main ( String [ ] args ) { String [ ] arr = { " abc " , " bcad " , " cabd " , " cba " , " dzzz " } ; int n = arr . length ; System . out . println ( count_acronym ( n , arr ) ) ; } }

Index/key variables: i, j, x
Accumulator variables: cnt, i, j
Iterator variables: i, j
Boolean variables: flag
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static boolean valid ( int [ ] cnt ) { for ( int i = 0 ; i < 26 ; i ++ ) { if ( cnt [ i ] >= 2 ) return false ; } return true ; } static String getGoodString ( String ss , int n ) { char [ ] s = ss . toCharArray ( ) ; if ( n < 26 ) return " - 1" ; int [ ] cnt = new int [ 27 ] ; for ( int i = 25 ; i < n ; i ++ ) { for ( int j = i ; j >= i - 25 ; j -- ) { if ( s [ j ] != ' ? ' ) cnt [ ( ( int ) s [ j ] - ( int ) ' a ' ) ] ++ ; } if ( valid ( cnt ) ) { int cur = 0 ; while ( cnt [ cur ] > 0 ) cur ++ ; for ( int j = i - 25 ; j <= i ; j ++ ) { if ( s [ j ] == ' ? ' ) { s [ j ] = ( char ) ( cur + ( int ) ( ' a ' ) ) ; cur ++ ; while ( cnt [ cur ] > 0 ) cur ++ ; } } return new String ( s ) ; } } return " - 1" ; } public static void main ( String [ ] args ) { String s = " abcdefghijkl ? nopqrstuvwxy ? " ; int n = s . length ( ) ; System . out . println ( getGoodString ( s , n ) ) ; } }

Index/key variables: cur, i, j
Accumulator variables: cur, i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
class GFG { 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 String swapRepeated ( char str [ ] ) { for ( int i = 0 ; i < str . length - 1 ; i ++ ) { char c = 0 ; if ( ( isVowel ( str [ i ] ) && isVowel ( str [ i + 1 ] ) ) || ( ! isVowel ( str [ i ] ) && ! isVowel ( str [ i + 1 ] ) ) ) { c = str [ i ] ; str [ i ] = str [ i + 1 ] ; str [ i + 1 ] = c ; } } return String . valueOf ( str ) ; } public static void main ( String [ ] args ) { String str = " geeksforgeeks " ; System . out . println ( swapRepeated ( str . toCharArray ( ) ) ) ; } }

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

Accumulator variables: i, res
Iterator variables: i
Class/struct names: GFG