dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
import java . io . * ; import java . lang . * ; import java . util . * ; class GFG { static int getMaxRepetitions ( String s1 , int n1 , String s2 , int n2 ) { int temp1 [ ] = new int [ 26 ] , temp2 [ ] = new int [ 26 ] ; for ( char i : s1 . toCharArray ( ) ) temp1 [ i - ' a ' ] ++ ; for ( char i : s2 . toCharArray ( ) ) temp2 [ i - ' a ' ] ++ ; for ( int i = 0 ; i < 26 ; i ++ ) { if ( temp2 [ i ] > temp1 [ i ] ) return 0 ; } int s1_reps = 0 ; int s2_reps = 0 ; HashMap < Integer , int [ ] > s2_index_to_reps = new HashMap < > ( ) ; s2_index_to_reps . put ( 0 , new int [ ] { 0 , 0 } ) ; int i = 0 ; int j = 0 ; while ( s1_reps < n1 ) { if ( s1 . charAt ( i ) == s2 . charAt ( j ) ) j += 1 ; i += 1 ; if ( j == s2 . length ( ) ) { j = 0 ; s2_reps += 1 ; } if ( i == s1 . length ( ) ) { i = 0 ; s1_reps += 1 ; if ( ! s2_index_to_reps . containsKey ( j ) ) break ; s2_index_to_reps . put ( j , new int [ ] { s1_reps , s2_reps } ) ; } } if ( s1_reps == n1 ) return s2_reps / n2 ; int initial_s1_reps = s2_index_to_reps . get ( j ) [ 0 ] , initial_s2_reps = s2_index_to_reps . get ( j ) [ 1 ] ; int loop_s1_reps = s1_reps - initial_s1_reps ; int loop_s2_reps = s2_reps - initial_s2_reps ; int loops = ( n1 - initial_s1_reps ) ; s2_reps = initial_s2_reps + loops * loop_s2_reps ; s1_reps = initial_s1_reps + loops * loop_s1_reps ; while ( s1_reps < n1 ) { if ( s1 . charAt ( i ) == s2 . charAt ( j ) ) j += 1 ; i += 1 ; if ( i == s1 . length ( ) ) { i = 0 ; s1_reps += 1 ; } if ( j == s2 . length ( ) ) { j = 0 ; s2_reps += 1 ; } } return s2_reps / n2 ; } public static void main ( String [ ] args ) { String s1 = " acb " ; int n1 = 4 ; String s2 = " ab " ; int n2 = 2 ; System . out . println ( getMaxRepetitions ( s1 , n1 , s2 , n2 ) ) ; } }

Index/key variables: i
Accumulator variables: i, j, s1_reps, s2_reps
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . lang . * ; import java . util . * ; class GFG { static String removeAdjacent ( String s ) { if ( s . length ( ) == 1 ) return s ; StringBuilder sb = new StringBuilder ( " " ) ; for ( int i = 0 ; i < s . length ( ) - 1 ; i ++ ) { char c = s . charAt ( i ) ; char d = s . charAt ( i + 1 ) ; if ( c != d ) { sb . append ( c ) ; if ( i == s . length ( ) - 2 ) { sb . append ( d ) ; } } else { for ( int j = i + 2 ; j < s . length ( ) ; j ++ ) sb . append ( s . charAt ( j ) ) ; return sb . toString ( ) ; } } return sb . toString ( ) ; } public static void reduceString ( String s ) { String result = " " ; String pre = s ; while ( true ) { result = removeAdjacent ( pre ) ; if ( result . equals ( pre ) ) break ; pre = result ; } if ( result . length ( ) != 0 ) System . out . println ( result ) ; else System . out . println ( " Empty ▁ String " ) ; } public static void main ( String [ ] args ) { String S = " aaabccddd " ; reduceString ( S ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
public class GFG { static int minDeletions ( String str ) { int fre [ ] = new int [ 26 ] ; int n = str . length ( ) ; for ( int i = 0 ; i < n ; i ++ ) { fre [ str . charAt ( i ) - ' a ' ] += 1 ; } int count = 0 ; for ( int i = 0 ; i < 26 ; i ++ ) { if ( fre [ i ] % 2 == 1 ) { count += 1 ; } } if ( count == 0 count == 1 ) { return 0 ; } else { return count - 1 ; } } public static void main ( String [ ] args ) { String str = " ababbccca " ; System . out . println ( minDeletions ( str ) ) ; } }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . lang . * ; import java . util . * ; class GFG { static void scoreOfParentheses ( String s ) { Stack < Integer > stack = new Stack < > ( ) ; stack . push ( 0 ) ; for ( char c : s . toCharArray ( ) ) { if ( c == ' ( ' ) stack . push ( 0 ) ; else { int tmp = stack . pop ( ) ; int val = 0 ; if ( tmp > 0 ) val = tmp * 2 ; else val = 1 ; stack . push ( stack . pop ( ) + val ) ; } } System . out . println ( stack . peek ( ) ) ; } public static void main ( String [ ] args ) { String S = " ( ( ) ( ( ) ) ) " ; scoreOfParentheses ( S ) ; } }

Iterator variables: c
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void findSubstringInWraproundString ( String p ) { int ans = 0 ; int curLen = 0 ; int arr [ ] = new int [ 26 ] ; for ( int i = 0 ; i < p . length ( ) ; i ++ ) { int curr = p . charAt ( i ) - ' a ' ; if ( i > 0 && ( p . charAt ( i - 1 ) != ( ( curr + 26 - 1 ) % 26 + ' a ' ) ) ) { curLen = 0 ; } curLen ++ ; if ( curLen > arr [ curr ] ) { ans += ( curLen - arr [ curr ] ) ; arr [ curr ] = curLen ; } } System . out . println ( ans ) ; } public static void main ( String args [ ] ) { String p = " zab " ; findSubstringInWraproundString ( p ) ; } }

Index/key variables: curr
Accumulator variables: ans, curLen, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int remove ( int N , int digit ) { String strN = String . valueOf ( N ) ; String ans = " " ; for ( char i : strN . toCharArray ( ) ) { if ( ( i - '0' ) == digit ) { continue ; } ans += i ; } return Integer . parseInt ( ans ) ; } static void getMin ( int [ ] arr ) { int minSum = Integer . MAX_VALUE ; for ( int i = 0 ; i < 10 ; i ++ ) { int curSum = 0 ; for ( int num : arr ) curSum += remove ( num , i ) ; minSum = Math . min ( minSum , curSum ) ; } System . out . print ( minSum ) ; } public static void main ( String [ ] args ) { int [ ] arr = { 34 , 23 , 85 , 93 } ; getMin ( arr ) ; } }

Accumulator variables: ans, curSum, i
Iterator variables: i, num
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class Solution { public int maxUniqueSplit ( String S ) { return maxUnique ( S , new HashSet < String > ( ) ) ; } public int maxUnique ( String S , Set < String > set ) { int max = 0 ; for ( int i = 1 ; i <= S . length ( ) ; i ++ ) { String tmp = S . substring ( 0 , i ) ; if ( ! set . contains ( tmp ) ) { set . add ( tmp ) ; max = Math . max ( max , maxUnique ( S . substring ( i ) , set ) + 1 ) ; set . remove ( tmp ) ; } } return max ; } } class GFG { public static void main ( String [ ] args ) { Solution st = new Solution ( ) ; String S = " ababccc " ; int res = st . maxUniqueSplit ( S ) ; System . out . println ( res ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG, Solution
Java program:
import java . util . * ; public class GFG { static void removeValidBracketSequences ( String str , int N ) { Vector < Integer > A = new Vector < Integer > ( ) ; Vector < Integer > B = new Vector < Integer > ( ) ; Vector < Integer > C = new Vector < Integer > ( ) ; boolean [ ] vis = new boolean [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { vis [ i ] = true ; } for ( int i = 0 ; i < N ; i ++ ) { if ( str . charAt ( i ) == ' ( ' ) { A . add ( i ) ; } else if ( str . charAt ( i ) == ' { ' ) { B . add ( i ) ; } else if ( str . charAt ( i ) == ' [ ' ) { C . add ( i ) ; } else if ( str . charAt ( i ) == ' ) ' && ( A . size ( ) > 0 ) ) { vis [ A . get ( A . size ( ) - 1 ) ] = false ; A . remove ( A . size ( ) - 1 ) ; vis [ i ] = false ; } else if ( str . charAt ( i ) == ' } ' && ( B . size ( ) > 0 ) ) { vis [ B . get ( B . size ( ) - 1 ) ] = false ; B . remove ( B . size ( ) - 1 ) ; vis [ i ] = false ; } else if ( str . charAt ( i ) == ' ] ' && ( C . size ( ) > 0 ) ) { vis [ C . get ( C . size ( ) - 1 ) ] = false ; C . remove ( C . size ( ) - 1 ) ; vis [ i ] = false ; } } for ( int i = 0 ; i < N ; ++ i ) { if ( vis [ i ] ) System . out . print ( str . charAt ( i ) ) ; } } public static void main ( String [ ] args ) { String str = " ( ( ) { ( ) ( { } ) " ; int N = str . length ( ) ; removeValidBracketSequences ( str , N ) ; } }

Index/key variables: N, i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void update ( int BIT [ ] [ ] , int idx , int i , int val ) { while ( i < 10005 ) { BIT [ idx ] [ i ] += val ; i = i + ( i & ( - i ) ) ; } } static int query ( int BIT [ ] [ ] , int idx , int i ) { int ans = 0 ; while ( i > 0 ) { ans += BIT [ idx ] [ i ] ; i = i - ( i & ( - i ) ) ; } return ans ; } static void maxDiffFreq ( String s , int [ ] [ ] queries ) { int [ ] [ ] BIT = new int [ 26 ] [ 10005 ] ; int n = s . length ( ) ; for ( int i = 0 ; i < n ; i ++ ) { update ( BIT , s . charAt ( i ) - ' a ' , i + 1 , 1 ) ; } int Q = queries . length ; for ( int i = 0 ; i < Q ; ++ i ) { int mx = 0 ; int mn = Integer . MAX_VALUE ; int l = queries [ i ] [ 0 ] ; int r = queries [ i ] [ 1 ] ; for ( int j = 0 ; j < 26 ; j ++ ) { int p = query ( BIT , j , r ) ; int q = query ( BIT , j , l - 1 ) ; mx = Math . max ( mx , p - q ) ; if ( p > 0 ) { mn = Math . min ( mn , p - q ) ; } } System . out . print ( mx - mn + "NEW_LINE"); } } public static void main ( String [ ] args ) { String S = " abaabac " ; int [ ] [ ] queries = { { 2 , 6 } , { 1 , 7 } } ; maxDiffFreq ( S , queries ) ; } }

Index/key variables: i, idx
Accumulator variables: ans, i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int minOperation ( String arr [ ] , int N ) { int cntMinOP = 0 ; int M = arr [ 0 ] . length ( ) ; int [ ] [ ] hash = new int [ 256 ] [ M ] ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < M ; j ++ ) { hash [ arr [ i ] . charAt ( j ) ] [ j ] ++ ; } } for ( int i = 0 ; i < M ; i ++ ) { int Sum = 0 ; int Max = 0 ; for ( int j = 0 ; j < 256 ; j ++ ) { Sum += hash [ j ] [ i ] ; Max = Math . max ( Max , hash [ j ] [ i ] ) ; } cntMinOP += ( Sum - Max ) ; } return cntMinOP ; } public static void main ( String [ ] args ) { String arr [ ] = { " abcd " , " bcde " , " cdef " } ; int N = arr . length ; System . out . print ( minOperation ( arr , N ) + "NEW_LINE"); } }

Index/key variables: M, i, j
Accumulator variables: Sum, cntMinOP, i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void countStrings ( String s , int k ) { int ans = 1 ; int len = s . length ( ) ; int flag = 0 ; int start_ind = 0 ; for ( int i = 0 ; i < len - 1 ; i ++ ) { if ( s . charAt ( i ) - '0' + s . charAt ( i + 1 ) - '0' == k && flag == 0 ) { flag = 1 ; start_ind = i ; } if ( flag == 1 && s . charAt ( i ) - '0' + s . charAt ( i + 1 ) - '0' != k ) { flag = 0 ; if ( ( i - start_ind + 1 ) % 2 != 0 ) ans *= ( i - start_ind + 1 - 1 ) / 2 + 1 ; } } if ( flag == 1 && ( len - start_ind ) % 2 != 0 ) ans *= ( len - start_ind ) / 2 + 1 ; System . out . println ( ans ) ; } public static void main ( String [ ] args ) { String S = "313" ; int K = 4 ; countStrings ( S , K ) ; } }

Accumulator variables: ans, i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static void find_num ( String n ) { int ans = 0 ; char [ ] digitsOfN = n . toCharArray ( ) ; int sumOfDigitsN = 0 ; for ( char c : digitsOfN ) { sumOfDigitsN += Integer . parseInt ( Character . toString ( c ) ) ; } for ( int x = 11 ; x > 0 ; x ++ ) { int newNum = x * Integer . parseInt ( n ) ; int tempSumDigits = 0 ; char [ ] temp = Integer . toString ( newNum ) . toCharArray ( ) ; for ( char c : temp ) { tempSumDigits += Integer . parseInt ( Character . toString ( c ) ) ; } if ( tempSumDigits == sumOfDigitsN ) { ans = x ; break ; } } System . out . println ( ans ) ; } public static void main ( String [ ] args ) { String N = "3029" ; find_num ( N ) ; } }

Accumulator variables: sumOfDigitsN, tempSumDigits, x
Iterator variables: c, x
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { static void findDisStr ( List < String > arr , int N ) { Set < String > DistString = new HashSet < String > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { if ( ! DistString . contains ( arr . get ( i ) ) ) { DistString . add ( arr . get ( i ) ) ; } } for ( String string : DistString ) { System . out . print ( string + " ▁ " ) ; } } public static void main ( String [ ] args ) { List < String > arr = Arrays . asList ( new String [ ] { " Geeks " , " For " , " Geeks " , " Code " , " Coder " } ) ; int N = arr . size ( ) ; findDisStr ( arr , N ) ; } }

Accumulator variables: i
Iterator variables: i, string
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static String modifyString ( int A [ ] , String str , int K ) { int N = str . length ( ) ; int count [ ] = new int [ N + 1 ] ; for ( int i = 0 ; i < K ; i ++ ) { count [ A [ i ] ] ++ ; } for ( int i = 1 ; i <= N / 2 ; i ++ ) { count [ i ] = count [ i ] + count [ i - 1 ] ; if ( ( count [ i ] & 1 ) > 0 ) { str = swap ( str , i - 1 , N - i ) ; } } return str ; } static String swap ( String str , int i , int j ) { char ch [ ] = str . toCharArray ( ) ; char temp = ch [ i ] ; ch [ i ] = ch [ j ] ; ch [ j ] = temp ; return String . valueOf ( ch ) ; } public static void main ( String [ ] args ) { String str = " abcdef " ; int arr [ ] = { 1 , 2 , 3 } ; int K = arr . length ; System . out . print ( modifyString ( arr , str , K ) ) ; } }

Index/key variables: i, j
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int __gcd ( int a , int b ) { return b == 0 ? a : __gcd ( b , a % b ) ; } static void findFraction ( String s ) { String be_deci = " " , af_deci = " " , reccu = " " ; boolean x = true , y = false , z = false ; for ( int i = 0 ; i < s . length ( ) ; ++ i ) { if ( s . charAt ( i ) == ' . ' ) { x = false ; y = true ; continue ; } if ( s . charAt ( i ) == ' ( ' ) { z = true ; y = false ; continue ; } if ( x ) be_deci += s . charAt ( i ) ; if ( y ) af_deci += s . charAt ( i ) ; if ( z ) { for ( ; i < s . length ( ) && s . charAt ( i ) != ' ) ' ; ++ i ) reccu += s . charAt ( i ) ; break ; } } int num_be_deci = Integer . valueOf ( be_deci ) ; int num_af_deci = 0 ; if ( af_deci . length ( ) != 0 ) num_af_deci = Integer . valueOf ( af_deci ) ; int numr = num_be_deci * ( int ) Math . pow ( 10 , af_deci . length ( ) ) + num_af_deci ; int deno = ( int ) Math . pow ( 10 , af_deci . length ( ) ) ; if ( reccu . length ( ) == 0 ) { int gd = __gcd ( numr , deno ) ; System . out . print ( numr / gd + " ▁ / ▁ " + deno / gd ) ; } else { int reccu_num = Integer . valueOf ( reccu ) ; int numr1 = numr * ( int ) Math . pow ( 10 , reccu . length ( ) ) + reccu_num ; int deno1 = deno * ( int ) Math . pow ( 10 , reccu . length ( ) ) ; int res_numr = numr1 - numr , res_deno = deno1 - deno ; int gd = __gcd ( res_numr , res_deno ) ; System . out . print ( res_numr / gd + " ▁ / ▁ " + res_deno / gd ) ; } } public static void main ( String [ ] args ) { String str = "23.98(231 ) " ; findFraction ( str ) ; } }

Accumulator variables: af_deci, be_deci, reccu
Iterator variables: i
Boolean variables: x, y, z
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static boolean lexi_largest_String ( int a [ ] , int i , int sum , Vector < Integer > v ) { if ( sum < 0 ) return false ; if ( sum == 0 ) return true ; if ( i < 0 ) return false ; v . add ( i ) ; if ( lexi_largest_String ( a , i , sum - a [ i ] , v ) ) return true ; v . remove ( v . size ( ) - 1 ) ; return lexi_largest_String ( a , i - 1 , sum , v ) ; } static void generateString ( int a [ ] , int sum ) { Vector < Integer > v = new Vector < Integer > ( ) ; lexi_largest_String ( a , 25 , sum , v ) ; String s = " " ; for ( int j = 0 ; j < v . size ( ) ; j ++ ) s += ( char ) ( v . get ( j ) + ' a ' ) ; System . out . print ( s + "NEW_LINE"); } public static void main ( String [ ] args ) { int a [ ] = { 1 , 1 , 2 , 33 , 4 , 6 , 9 , 7 , 36 , 32 , 58 , 32 , 28 , 904 , 22 , 255 , 47 , 69 , 558 , 544 , 21 , 36 , 48 , 85 , 48 , 58 } ; int sum = 236 ; generateString ( a , sum ) ; } }

Index/key variables: i
Accumulator variables: j, s
Iterator variables: j
Class/struct names: GFG
Java program:
class GFG { static int fact ( int a ) { int i , f = 1 ; for ( i = 2 ; i <= a ; i ++ ) f = f * i ; return f ; } static int permute ( int n , int r ) { int ans = 0 ; ans = ( fact ( n ) / fact ( n - r ) ) ; return ans ; } static int findPermutations ( int n ) { int sum = 0 , P ; for ( int r = 1 ; r <= n ; r ++ ) { P = permute ( n , r ) ; sum = sum + P ; } return sum ; } public static void main ( String [ ] args ) { String str = " xz " ; int result , n ; n = str . length ( ) ; System . out . print ( findPermutations ( n ) ) ; } }

Accumulator variables: i, r
Iterator variables: i, r
Class/struct names: GFG
Java program:
public class Main { public static final int V = 5 ; static int count = 0 ; static void DFS ( int graph [ ] [ ] , boolean marked [ ] , int n , int vert , int start ) { marked [ vert ] = true ; if ( n == 0 ) { marked [ vert ] = false ; if ( graph [ vert ] [ start ] == 1 ) { count ++ ; return ; } else return ; } for ( int i = 0 ; i < V ; i ++ ) if ( ! marked [ i ] && graph [ vert ] [ i ] == 1 ) DFS ( graph , marked , n - 1 , i , start ) ; marked [ vert ] = false ; } static int countCycles ( int graph [ ] [ ] , int n ) { boolean marked [ ] = new boolean [ V ] ; for ( int i = 0 ; i < V - ( n - 1 ) ; i ++ ) { DFS ( graph , marked , n - 1 , i , i ) ; marked [ i ] = true ; } return count / 2 ; } public static void main ( String [ ] args ) { int graph [ ] [ ] = { { 0 , 1 , 0 , 1 , 0 } , { 1 , 0 , 1 , 0 , 1 } , { 0 , 1 , 0 , 1 , 0 } , { 1 , 0 , 1 , 0 , 1 } , { 0 , 1 , 0 , 1 , 0 } } ; int n = 4 ; System . out . println ( " Total ▁ cycles ▁ of ▁ length ▁ " + n + " ▁ are ▁ " + countCycles ( graph , n ) ) ; } }

Index/key variables: V, i, start, vert
Accumulator variables: count, i
Iterator variables: i
Class/struct names: Main
Java program:
class GFG { static long polynomialRollingHash ( String str ) { int p = 31 ; int m = ( int ) ( 1e9 + 9 ) ; long power_of_p = 1 ; long hash_val = 0 ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { hash_val = ( hash_val + ( str . charAt ( i ) - ' a ' + 1 ) * power_of_p ) % m ; power_of_p = ( power_of_p * p ) % m ; } return hash_val ; } public static void main ( String [ ] args ) { String str1 = " geeksforgeeks " ; String str2 = " geeks " ; System . out . print ( " Hash ▁ of ▁ ' " + str1 + " ' ▁ = ▁ " + polynomialRollingHash ( str1 ) ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . LinkedList ; public class FirstNonRepeatingElement { static void firstNonRepElement ( String str ) { LinkedList < Character > list = new LinkedList < Character > ( ) ; list . add ( str . charAt ( 0 ) ) ; for ( int i = 1 ; i < str . length ( ) ; i ++ ) { if ( list . contains ( str . charAt ( i ) ) ) list . remove ( list . indexOf ( str . charAt ( i ) ) ) ; else list . add ( str . charAt ( i ) ) ; } System . out . println ( list . get ( 0 ) ) ; } public static void main ( String [ ] args ) { String str = " geeksforgeeks " ; firstNonRepElement ( str ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: FirstNonRepeatingElement
Java program:
import java . util . * ; class GFG { static void stateA ( String n ) { if ( n . charAt ( 0 ) == ' a ' ) { stateB ( n . substring ( 1 ) ) ; } else { stateQ ( n ) ; } } static void stateB ( String n ) { if ( n . length ( ) == 0 ) { System . out . print ( " Accepted " ) ; } else { if ( n . charAt ( 0 ) == ' a ' ) stateC ( n . substring ( 1 ) ) ; else stateD ( n . substring ( 1 ) ) ; } } static void stateC ( String n ) { if ( n . length ( ) == 0 ) System . out . print ( " Accepted " ) ; else { if ( n . charAt ( 0 ) == ' a ' ) stateC ( n . substring ( 1 ) ) ; else stateQ ( n ) ; } } static void stateD ( String n ) { if ( n . length ( ) == 0 ) System . out . print ( " Accepted " ) ; else { if ( n . charAt ( 0 ) == ' a ' ) { stateB ( n . substring ( 1 ) ) ; } else { stateD ( n . substring ( 1 ) ) ; } } } static void stateQ ( String n ) { System . out . print ( " Not ▁ Accepted " ) ; } public static void main ( String [ ] args ) { String n = " aaaba " ; stateA ( n ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; class GFG { public static int countSubstrings ( String str , int K ) { int N = str . length ( ) ; int answer = 0 ; Map < Character , Integer > map = new HashMap < Character , Integer > ( ) ; for ( int i = 0 ; i < K ; i ++ ) { if ( map . get ( str . charAt ( i ) ) == null ) { map . put ( str . charAt ( i ) , 1 ) ; } else { map . put ( str . charAt ( i ) , map . get ( str . charAt ( i ) ) + 1 ) ; } } if ( map . size ( ) == K ) answer ++ ; for ( int i = K ; i < N ; i ++ ) { if ( map . get ( str . charAt ( i ) ) == null ) { map . put ( str . charAt ( i ) , 1 ) ; } else { map . put ( str . charAt ( i ) , map . get ( str . charAt ( i ) ) + 1 ) ; } map . put ( str . charAt ( i - K ) , map . get ( str . charAt ( i - K ) ) - 1 ) ; if ( map . get ( str . charAt ( i - K ) ) == 0 ) { map . remove ( str . charAt ( i - K ) ) ; } if ( map . size ( ) == K ) { answer ++ ; } } return answer ; } public static void main ( String [ ] args ) { String str = " aabcdabbcdc " ; int K = 3 ; System . out . println ( countSubstrings ( str , K ) ) ; } }

Accumulator variables: answer, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; public class Main { static HashMap < String , Boolean > mp = new HashMap < String , Boolean > ( ) ; static boolean isScramble ( String S1 , String S2 ) { if ( S1 . length ( ) != S2 . length ( ) ) { return false ; } int n = S1 . length ( ) ; if ( n != 0 ) { return true ; } if ( S1 == S2 ) { return true ; } String copy_S1 = S1 , copy_S2 = S2 ; char [ ] t1 = copy_S1 . toCharArray ( ) ; char [ ] t2 = copy_S2 . toCharArray ( ) ; Arrays . sort ( t1 ) ; Arrays . sort ( t2 ) ; copy_S1 = new String ( t1 ) ; copy_S2 = new String ( t2 ) ; if ( ! copy_S1 . equals ( copy_S2 ) ) { return false ; } String key = ( S1 + " ▁ " + S2 ) ; if ( mp . containsKey ( key ) ) { return mp . get ( key ) ; } boolean flag = false ; for ( int i = 1 ; i < n ; i ++ ) { if ( isScramble ( S1 . substring ( 0 , i ) , S2 . substring ( 0 , i ) ) && isScramble ( S1 . substring ( i , n ) , S2 . substring ( i , n ) ) ) { flag = true ; return true ; } if ( isScramble ( S1 . substring ( 0 , i ) , S2 . substring ( n - i , n ) ) && isScramble ( S1 . substring ( i , n ) , S2 . substring ( 0 , n - i ) ) ) { flag = true ; return true ; } } mp . put ( key , flag ) ; return false ; } public static void main ( String [ ] args ) { String S1 = " coder " ; String S2 = " ocred " ; if ( isScramble ( S1 , S2 ) ) { System . out . print ( " Yes " ) ; } else { System . out . print ( " No " ) ; } } }

Accumulator variables: i
Iterator variables: i
Boolean variables: flag
Class/struct names: Main
Java program:
import java . util . * ; class GFG { static void LongestPalindromicPrefix ( String s ) { int n = s . length ( ) ; int max_len = 0 ; for ( int len = 1 ; len <= n ; len ++ ) { String temp = s . substring ( 0 , len ) ; String temp2 = temp ; temp2 = reverse ( temp2 ) ; if ( temp . equals ( temp2 ) ) { max_len = len ; } } System . out . print ( s . substring ( 0 , max_len ) ) ; } static String reverse ( String input ) { char [ ] a = input . toCharArray ( ) ; int l , r = a . length - 1 ; for ( l = 0 ; l < r ; l ++ , r -- ) { char temp = a [ l ] ; a [ l ] = a [ r ] ; a [ r ] = temp ; } return String . valueOf ( a ) ; } public static void main ( String [ ] args ) { String str = " abaab " ; LongestPalindromicPrefix ( str ) ; } }

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

Index/key variables: i, n
Accumulator variables: i, k, s
Iterator variables: i
Class/struct names: GFG