dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
class GFG { static final int max = 100 ; static void carveCross ( String str ) { int n = str . length ( ) ; if ( n % 2 == 0 ) { System . out . print ( " Not ▁ possible . ▁ Please ▁ enter ▁ " + "odd length string.NEW_LINE"); } else { char arr [ ] [ ] = new char [ max ] [ max ] ; int m = n / 2 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { arr [ i ] [ j ] = ' X ' ; } } for ( int i = 0 ; i < n ; i ++ ) { arr [ i ] [ m ] = str . charAt ( i ) ; } for ( int i = 0 ; i < n ; i ++ ) { arr [ m ] [ i ] = str . charAt ( i ) ; } for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { System . out . print ( arr [ i ] [ j ] + " ▁ " ) ; } System . out . print ( "NEW_LINE"); } } } public static void main ( String [ ] args ) { String str = " PICTURE " ; carveCross ( str ) ; } }

Index/key variables: i, j, m, max
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
class GFG { static void generateString ( int n ) { String s = " " ; for ( int i = 0 ; i < n ; i ++ ) s += ( ( i & 2 ) > 1 ? ' b ' : ' a ' ) ; System . out . println ( s ) ; } public static void main ( String [ ] args ) { int n = 5 ; generateString ( n ) ; n = 8 ; generateString ( n ) ; n = 10 ; generateString ( n ) ; } }

Accumulator variables: i, s
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . ArrayList ; import java . util . Arrays ; import java . util . HashMap ; import java . util . HashSet ; import java . util . Map ; import java . util . SortedMap ; import java . util . TreeMap ; class Graph { static String subsequence ( String s , int binary , int len ) { String sub = " " ; for ( int j = 0 ; j < len ; j ++ ) if ( ( binary & ( 1 << j ) ) != 0 ) sub += s . charAt ( j ) ; return sub ; } static void possibleSubsequences ( String s ) { SortedMap < Integer , HashSet < String > > sorted_subsequence = new TreeMap < Integer , HashSet < String > > ( ) ; int len = s . length ( ) ; int limit = ( int ) Math . pow ( 2 , len ) ; for ( int i = 1 ; i <= limit - 1 ; i ++ ) { String sub = subsequence ( s , i , len ) ; if ( ! sorted_subsequence . containsKey ( sub . length ( ) ) ) sorted_subsequence . put ( sub . length ( ) , new HashSet < > ( ) ) ; sorted_subsequence . get ( sub . length ( ) ) . add ( sub ) ; } for ( Map . Entry < Integer , HashSet < String > > it : sorted_subsequence . entrySet ( ) ) { System . out . println ( " Subsequences ▁ of ▁ length ▁ = ▁ " + it . getKey ( ) + " ▁ are : " ) ; for ( String ii : it . getValue ( ) ) System . out . print ( ii + " ▁ " ) ; System . out . println ( ) ; } } public static void main ( String [ ] args ) { String s = " aabc " ; possibleSubsequences ( s ) ; } }

Accumulator variables: i, j, sub
Iterator variables: i, ii, j
Class/struct names: Graph
Java program:
import java . io . * ; class GFG { static int remainder ( String str ) { int len = str . length ( ) ; int num , rem = 0 ; for ( int i = 0 ; i < len ; i ++ ) { num = rem * 10 + ( str . charAt ( i ) - '0' ) ; rem = num % 11 ; } return rem ; } public static void main ( String args [ ] ) { String str = "3435346456547566345436457867978" ; System . out . println ( remainder ( str ) ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { public static int longestSubseq ( String s ) { int n = s . length ( ) ; int [ ] pre_count_0 = new int [ n + 2 ] ; int [ ] pre_count_1 = new int [ n + 1 ] ; int [ ] post_count_0 = new int [ n + 2 ] ; pre_count_0 [ 0 ] = 0 ; post_count_0 [ n + 1 ] = 0 ; pre_count_1 [ 0 ] = 0 ; for ( int j = 1 ; j <= n ; j ++ ) { pre_count_0 [ j ] = pre_count_0 [ j - 1 ] ; pre_count_1 [ j ] = pre_count_1 [ j - 1 ] ; post_count_0 [ n - j + 1 ] = post_count_0 [ n - j + 2 ] ; if ( s . charAt ( j - 1 ) == '0' ) pre_count_0 [ j ] ++ ; else pre_count_1 [ j ] ++ ; if ( s . charAt ( n - j ) == '0' ) post_count_0 [ n - j + 1 ] ++ ; } if ( pre_count_0 [ n ] == n pre_count_0 [ n ] == 0 ) return n ; int ans = 0 ; for ( int i = 1 ; i <= n ; i ++ ) for ( int j = i ; j <= n ; j ++ ) ans = Math . max ( pre_count_0 [ i - 1 ] + pre_count_1 [ j ] - pre_count_1 [ i - 1 ] + post_count_0 [ j + 1 ] , ans ) ; return ans ; } public static void main ( String [ ] args ) { String s = "000011100000" ; System . out . println ( longestSubseq ( s ) ) ; } }

Index/key variables: j, n
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
public class GFG { static boolean shouldSwap ( char str [ ] , int start , int curr ) { for ( int i = start ; i < curr ; i ++ ) { if ( str [ i ] == str [ curr ] ) { return false ; } } return true ; } static void findPermutations ( char str [ ] , int index , int n ) { if ( index >= n ) { System . out . println ( str ) ; return ; } for ( int i = index ; i < n ; i ++ ) { boolean check = shouldSwap ( str , index , i ) ; if ( check ) { swap ( str , index , i ) ; findPermutations ( str , index + 1 , n ) ; swap ( str , index , i ) ; } } } static void swap ( char [ ] str , int i , int j ) { char c = str [ i ] ; str [ i ] = str [ j ] ; str [ j ] = c ; } public static void main ( String [ ] args ) { char str [ ] = { ' A ' , ' B ' , ' C ' , ' A ' } ; int n = str . length ; findPermutations ( str , 0 , n ) ; } }

Index/key variables: curr, i, j
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static void findPermutations ( char str [ ] , int index , int n ) { if ( index >= n || ( index + 1 ) >= n ) { System . out . println ( str ) ; return ; } findPermutations ( str , index + 1 , n ) ; swap ( str , index ) ; findPermutations ( str , index + 2 , n ) ; swap ( str , index ) ; } static void swap ( char arr [ ] , int index ) { char temp = arr [ index ] ; arr [ index ] = arr [ index + 1 ] ; arr [ index + 1 ] = temp ; } public static void main ( String [ ] args ) { char str [ ] = "12345" . toCharArray ( ) ; int n = str . length ; findPermutations ( str , 0 , n ) ; } }

Index/key variables: index
Class/struct names: GFG
Java program:
public class GFG { static String decodeMedianString ( String s ) { int l = s . length ( ) ; String s1 = " " ; boolean isEven = ( l % 2 == 0 ) ? true : false ; for ( int i = 0 ; i < l ; i += 2 ) { if ( isEven ) { s1 = s . charAt ( i ) + s1 ; s1 += s . charAt ( i + 1 ) ; } else { if ( l - i > 1 ) { s1 += s . charAt ( i ) ; s1 = s . charAt ( i + 1 ) + s1 ; } else { s1 += s . charAt ( i ) ; } } } return s1 ; } public static void main ( String args [ ] ) { String s = " eekgs " ; System . out . println ( decodeMedianString ( s ) ) ; } }

Accumulator variables: i, s1
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int maximumChars ( String str ) { int n = str . length ( ) ; int res = - 1 ; for ( int i = 0 ; i < n - 1 ; i ++ ) for ( int j = i + 1 ; j < n ; j ++ ) if ( str . charAt ( i ) == str . charAt ( j ) ) res = Math . max ( res , Math . abs ( j - i - 1 ) ) ; return res ; } public static void main ( String [ ] args ) { String str = " abba " ; System . out . println ( maximumChars ( str ) ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . io . * ; public class GFG { static int MAX_CHAR = 256 ; static int maximumChars ( String str ) { int n = str . length ( ) ; int res = - 1 ; int [ ] firstInd = new int [ MAX_CHAR ] ; for ( int i = 0 ; i < MAX_CHAR ; i ++ ) firstInd [ i ] = - 1 ; for ( int i = 0 ; i < n ; i ++ ) { int first_ind = firstInd [ str . charAt ( i ) ] ; if ( first_ind == - 1 ) firstInd [ str . charAt ( i ) ] = i ; else res = Math . max ( res , Math . abs ( i - first_ind - 1 ) ) ; } return res ; } static public void main ( String [ ] args ) { String str = " abba " ; System . out . println ( maximumChars ( str ) ) ; } }

Index/key variables: MAX_CHAR, i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static boolean isUnique ( int [ ] a , int n , int k ) { int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) sum += a [ i ] ; sum += n - 1 ; return ( sum == k ) ; } static public void main ( String [ ] args ) { int [ ] a = { 3 , 3 , 3 } ; int n = a . length ; int k = 12 ; if ( isUnique ( a , n , k ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } }

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { public static String nextWord ( String str ) { if ( str == " " ) return " a " ; int i = str . length ( ) - 1 ; while ( str . charAt ( i ) == ' z ' && i >= 0 ) i -- ; if ( i == - 1 ) str = str + ' a ' ; else str = str . substring ( 0 , i ) + ( char ) ( ( int ) ( str . charAt ( i ) ) + 1 ) + str . substring ( i + 1 ) ; return str ; } public static void main ( String [ ] args ) { String str = " samez " ; System . out . print ( nextWord ( str ) ) ; } }

Accumulator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { public static boolean isValid ( String p ) { int n = p . length ( ) ; int c1 = 0 , c0 = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( p . charAt ( i ) == '0' ) { c0 ++ ; } if ( p . charAt ( i ) == '1' ) { c1 ++ ; } } if ( c0 == c1 ) { return true ; } else { return false ; } } public static int longestSub ( String s ) { int max_len = 0 ; int n = s . length ( ) ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i ; j < n ; j ++ ) { if ( isValid ( s . substring ( i , j + 1 ) ) && max_len < j - i + 1 ) { max_len = j - i + 1 ; } } } return max_len ; } public static void main ( String [ ] args ) { String s = "101001000" ; System . out . println ( longestSub ( s ) ) ; } }

Accumulator variables: c0, c1, i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; import java . lang . * ; class GFG { static int MAX_CHAR = 26 ; public static void commonCharacters ( String str [ ] , int n ) { Boolean [ ] prim = new Boolean [ MAX_CHAR ] ; Arrays . fill ( prim , new Boolean ( true ) ) ; for ( int i = 0 ; i < n ; i ++ ) { Boolean [ ] sec = new Boolean [ MAX_CHAR ] ; Arrays . fill ( sec , new Boolean ( false ) ) ; for ( int j = 0 ; j < str [ i ] . length ( ) ; j ++ ) { if ( prim [ str [ i ] . charAt ( j ) - ' a ' ] ) sec [ str [ i ] . charAt ( j ) - ' a ' ] = true ; } System . arraycopy ( sec , 0 , prim , 0 , MAX_CHAR ) ; } for ( int i = 0 ; i < 26 ; i ++ ) if ( prim [ i ] ) { System . out . print ( Character . toChars ( i + 97 ) ) ; System . out . print ( " ▁ " ) ; } } public static void main ( String [ ] args ) { String str [ ] = { " geeksforgeeks " , " gemkstones " , " acknowledges " , " aguelikes " } ; int n = str . length ; commonCharacters ( str , n ) ; } }

Index/key variables: MAX_CHAR, i
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static boolean isPalindrome ( String s , int i , int j ) { int p = j ; for ( int k = i ; k <= p ; k ++ ) { if ( s . charAt ( k ) != s . charAt ( p ) ) return false ; p -- ; } return true ; } static int countWays ( String s ) { int n = s . length ( ) ; int count = 0 ; if ( isPalindrome ( s , 0 , n - 1 ) ) { for ( int i = n / 2 ; i < n ; i ++ ) { if ( s . charAt ( i ) == s . charAt ( i + 1 ) ) count ++ ; else break ; } { count ++ ; } else } else { for ( int i = 0 ; i < n / 2 ; i ++ ) { if ( s . charAt ( i ) != s . charAt ( n - 1 - i ) ) { int j = n - 1 - i ; if ( isPalindrome ( s , i , n - 2 - i ) ) { for ( int k = i - 1 ; k >= 0 ; k -- ) { if ( s . charAt ( k ) != s . charAt ( j ) ) break ; count ++ ; } count ++ ; } if ( isPalindrome ( s , i + 1 , n - 1 - i ) ) { for ( int k = n - i ; k < n ; k ++ ) { if ( s . charAt ( k ) != s . charAt ( i ) ) break ; count ++ ; } count ++ ; } break ; } } } return count ; } public static void main ( String [ ] args ) { String s = " abca " ; System . out . println ( countWays ( s ) ) ; } }

Accumulator variables: count, i, k, p
Iterator variables: i, k
Class/struct names: GFG
Java program:
import java . io . * ; public class GFG { static int countOfSubstringWithKOnes ( String s , int K ) { int N = s . length ( ) ; int res = 0 ; int countOfOne = 0 ; int [ ] freq = new int [ N + 1 ] ; freq [ 0 ] = 1 ; for ( int i = 0 ; i < N ; i ++ ) { countOfOne += ( s . charAt ( i ) - '0' ) ; if ( countOfOne >= K ) { res += freq [ countOfOne - K ] ; } freq [ countOfOne ] ++ ; } return res ; } static public void main ( String [ ] args ) { String s = "10010" ; int K = 1 ; System . out . println ( countOfSubstringWithKOnes ( s , K ) ) ; } }

Index/key variables: countOfOne
Accumulator variables: countOfOne, i, res
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { final static int MAX_CHAR = 256 ; static void printDuo ( String str ) { int countChar [ ] = new int [ MAX_CHAR ] ; int n = str . length ( ) ; for ( int i = 0 ; i < n ; i ++ ) { countChar [ str . charAt ( i ) - ' a ' ] ++ ; } String str1 = " " , str2 = " " ; for ( int i = 0 ; i < MAX_CHAR ; i ++ ) { if ( countChar [ i ] > 1 ) { str2 = str2 + ( char ) ( i + ' a ' ) ; } else if ( countChar [ i ] == 1 ) { str1 = str1 + ( char ) ( i + ' a ' ) ; } } System . out . print ( " String ▁ with ▁ characters ▁ occurring ▁ " + "once:NEW_LINE"); System . out . print ( str1 + "NEW_LINE"); System . out . print ( " String ▁ with ▁ characters ▁ occurring ▁ " + "multiple times:NEW_LINE"); System . out . print ( str2 + "NEW_LINE"); System . out . print ( " " ) ; } public static void main ( String [ ] args ) { String str = " lovetocode " ; printDuo ( str ) ; } }

Index/key variables: MAX_CHAR, i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class NextHigherPalindrome { public static void reverse ( char num [ ] , int i , int j ) { while ( i < j ) { char temp = num [ i ] ; num [ i ] = num [ j ] ; num [ j ] = temp ; i ++ ; j -- ; } } public static void nextPalin ( char num [ ] , int n ) { if ( n <= 3 ) { System . out . println ( " Not ▁ Possible " ) ; return ; } char temp ; int mid = n / 2 - 1 ; int i , j ; for ( i = mid - 1 ; i >= 0 ; i -- ) if ( num [ i ] < num [ i + 1 ] ) break ; if ( i < 0 ) { System . out . println ( " Not ▁ Possible " ) ; return ; } int smallest = i + 1 ; for ( j = i + 2 ; j <= mid ; j ++ ) if ( num [ j ] > num [ i ] && num [ j ] <= num [ smallest ] ) smallest = j ; temp = num [ i ] ; num [ i ] = num [ smallest ] ; num [ smallest ] = temp ; temp = num [ n - i - 1 ] ; num [ n - i - 1 ] = num [ n - smallest - 1 ] ; num [ n - smallest - 1 ] = temp ; reverse ( num , i + 1 , mid ) ; if ( n % 2 == 0 ) reverse ( num , mid + 1 , n - i - 2 ) ; else reverse ( num , mid + 2 , n - i - 2 ) ; String result = String . valueOf ( num ) ; System . out . println ( " Next ▁ Palindrome : ▁ " + result ) ; } public static void main ( String args [ ] ) { String str = "4697557964" ; char num [ ] = str . toCharArray ( ) ; int n = str . length ( ) ; nextPalin ( num , n ) ; } }

Index/key variables: i, j, smallest
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: NextHigherPalindrome
Java program:
import java . io . * ; class GFG { static void printRec ( String number , int extraOnes , int remainingPlaces ) { if ( 0 == remainingPlaces ) { System . out . print ( number + " ▁ " ) ; return ; } printRec ( number + "1" , extraOnes + 1 , remainingPlaces - 1 ) ; if ( 0 < extraOnes ) printRec ( number + "0" , extraOnes - 1 , remainingPlaces - 1 ) ; } static void printNums ( int n ) { String str = " " ; printRec ( str , 0 , n ) ; } public static void main ( String [ ] args ) { int n = 4 ; printNums ( n ) ; } }

Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class stem { public static String findstem ( String arr [ ] ) { int n = arr . length ; String s = arr [ 0 ] ; int len = s . length ( ) ; String res = " " ; for ( int i = 0 ; i < len ; i ++ ) { for ( int j = i + 1 ; j <= len ; j ++ ) { String stem = s . substring ( i , j ) ; int k = 1 ; for ( k = 1 ; k < n ; k ++ ) if ( ! arr [ k ] . contains ( stem ) ) break ; if ( k == n && res . length ( ) < stem . length ( ) ) res = stem ; } } return res ; } public static void main ( String args [ ] ) { String arr [ ] = { " grace " , " graceful " , " disgraceful " , " gracefully " } ; String stems = findstem ( arr ) ; System . out . println ( stems ) ; } }

Index/key variables: k
Accumulator variables: i, j, k
Iterator variables: i, j, k
Class/struct names: stem
Java program:
class StringfromCharacters { static final int MAX_CHAR = 256 ; static boolean isPossible ( String s1 , String s2 ) { int count [ ] = new int [ MAX_CHAR ] ; for ( int i = 0 ; i < s2 . length ( ) ; i ++ ) count [ ( int ) s2 . charAt ( i ) ] ++ ; for ( int i = 0 ; i < s1 . length ( ) ; i ++ ) { if ( count [ ( int ) s1 . charAt ( i ) ] == 0 ) return false ; count [ ( int ) s1 . charAt ( i ) ] -- ; } return true ; } public static void main ( String args [ ] ) { String s1 = " GeeksforGeeks " , s2 = " rteksfoGrdsskGeggehes " ; if ( isPossible ( s1 , s2 ) ) System . out . println ( " Possible " ) ; else System . out . println ( " Not ▁ Possible " ) ; } }

Index/key variables: MAX_CHAR
Accumulator variables: i
Iterator variables: i
Class/struct names: StringfromCharacters
Java program:
class GFG { static String nextHighUsingAtMostOneSwap ( String st ) { char num [ ] = st . toCharArray ( ) ; int l = num . length ; int posRMax = l - 1 ; int index = - 1 ; for ( int i = l - 2 ; i >= 0 ; i -- ) { if ( num [ i ] >= num [ posRMax ] ) posRMax = i ; else { index = i ; break ; } } if ( index == - 1 ) return " Not ▁ Possible " ; int greatSmallDgt = - 1 ; for ( int i = l - 1 ; i > index ; i -- ) { if ( num [ i ] > num [ index ] ) { if ( greatSmallDgt == - 1 ) greatSmallDgt = i ; else if ( num [ i ] <= num [ greatSmallDgt ] ) greatSmallDgt = i ; } } char temp = num [ index ] ; num [ index ] = num [ greatSmallDgt ] ; num [ greatSmallDgt ] = temp ; return ( String . valueOf ( num ) ) ; } public static void main ( String [ ] args ) { String num = "218765" ; System . out . println ( " Original ▁ number : ▁ " + num ) ; System . out . println ( " Next ▁ higher ▁ number : ▁ " + nextHighUsingAtMostOneSwap ( num ) ) ; } }

Index/key variables: greatSmallDgt, i, index, posRMax
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static boolean isVowel ( char c ) { return ( c == ' a ' c == ' e ' c == ' i ' c == ' o ' c == ' u ' ) ; } static int longestVowel ( String str ) { int count = 0 , res = 0 ; char [ ] s = str . toCharArray ( ) ; for ( int i = 0 ; i < s . length ; i ++ ) { if ( isVowel ( s [ i ] ) ) count ++ ; else { res = Math . max ( res , count ) ; count = 0 ; } } return Math . max ( res , count ) ; } public static void main ( String [ ] args ) { String s = " theeare " ; System . out . println ( longestVowel ( s ) ) ; } }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int MAX_CHAR = 26 ; static boolean check ( int freq [ ] , int k ) { for ( int i = 0 ; i < MAX_CHAR ; i ++ ) if ( freq [ i ] != 0 && freq [ i ] != k ) return false ; return true ; } static int substrings ( String s , int k ) { for ( int i = 0 ; i < s . length ( ) ; i ++ ) { int freq [ ] = new int [ MAX_CHAR ] ; for ( int j = i ; j < s . length ( ) ; j ++ ) { int index = s . charAt ( j ) - ' a ' ; freq [ index ] ++ ; if ( freq [ index ] > k ) break ; else if ( freq [ index ] == k && check ( freq , k ) == true ) res ++ ; } } return res ; } public static void main ( String [ ] args ) { String s = " aabbcc " ; int k = 2 ; System . out . println ( substrings ( s , k ) ) ; s = " aabbc " ; k = 2 ; System . out . println ( substrings ( s , k ) ) ; } }

Index/key variables: MAX_CHAR, i, index
Accumulator variables: i, j, res
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static boolean have_same_frequency ( int [ ] freq , int k ) { for ( int i = 0 ; i < 26 ; i ++ ) { if ( freq [ i ] != 0 && freq [ i ] != k ) { return false ; } } return true ; } static int count_substrings ( String s , int k ) { int count = 0 ; int distinct = 0 ; boolean [ ] have = new boolean [ 26 ] ; Arrays . fill ( have , false ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { have [ ( ( int ) ( s . charAt ( i ) - ' a ' ) ) ] = true ; } for ( int i = 0 ; i < 26 ; i ++ ) { if ( have [ i ] ) { distinct ++ ; } } for ( int length = 1 ; length <= distinct ; length ++ ) { int window_length = length * k ; int [ ] freq = new int [ 26 ] ; Arrays . fill ( freq , 0 ) ; int window_start = 0 ; int window_end = window_start + window_length - 1 ; for ( int i = window_start ; i <= Math . min ( window_end , s . length ( ) - 1 ) ; i ++ ) { freq [ ( ( int ) ( s . charAt ( i ) - ' a ' ) ) ] ++ ; } while ( window_end < s . length ( ) ) { if ( have_same_frequency ( freq , k ) ) { count ++ ; } freq [ ( ( int ) ( s . charAt ( window_start ) - ' a ' ) ) ] -- ; window_start ++ ; window_end ++ ; if ( window_end < s . length ( ) ) { freq [ ( ( int ) ( s . charAt ( window_end ) - ' a ' ) ) ] ++ ; } } } return count ; } public static void main ( String [ ] args ) { String s = " aabbcc " ; int k = 2 ; System . out . println ( count_substrings ( s , k ) ) ; s = " aabbc " ; k = 2 ; System . out . println ( count_substrings ( s , k ) ) ; } }

Index/key variables: i
Accumulator variables: count, distinct, i, length, window_end, window_start
Iterator variables: i, length
Class/struct names: GFG
Java program:
class GFG { static final int MAX_CHARS = 26 ; static void longestSubseqWithK ( String str , int k ) { int n = str . length ( ) ; int freq [ ] = new int [ MAX_CHARS ] ; for ( int i = 0 ; i < n ; i ++ ) { freq [ str . charAt ( i ) - ' a ' ] ++ ; } for ( int i = 0 ; i < n ; i ++ ) { if ( freq [ str . charAt ( i ) - ' a ' ] >= k ) { System . out . print ( str . charAt ( i ) ) ; } } } static public void main ( String [ ] args ) { String str = " geeksforgeeks " ; int k = 2 ; longestSubseqWithK ( str , k ) ; } }

Index/key variables: MAX_CHARS
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void generate ( Set < String > st , String s ) { if ( s . length ( ) == 0 ) { return ; } if ( ! st . contains ( s ) ) { st . add ( s ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { String t = s ; t = t . substring ( 0 , i ) + t . substring ( i + 1 ) ; generate ( st , t ) ; } } return ; } public static void main ( String args [ ] ) { String s = " xyz " ; TreeSet < String > st = new TreeSet < > ( ) ; generate ( st , s ) ; for ( String str : st ) { System . out . println ( str ) ; } } }

Accumulator variables: i
Iterator variables: i, str
Class/struct names: GFG
Java program:
import java . util . HashSet ; public class Subsequence { static HashSet < String > st = new HashSet < > ( ) ; static void subsequence ( String str ) { for ( int i = 0 ; i < str . length ( ) ; i ++ ) { for ( int j = str . length ( ) ; j > i ; j -- ) { String sub_str = str . substring ( i , j ) ; if ( ! st . contains ( sub_str ) ) st . add ( sub_str ) ; for ( int k = 1 ; k < sub_str . length ( ) - 1 ; k ++ ) { StringBuffer sb = new StringBuffer ( sub_str ) ; sb . deleteCharAt ( k ) ; if ( ! st . contains ( sb ) ) ; subsequence ( sb . toString ( ) ) ; } } } } public static void main ( String [ ] args ) { String s = " aabc " ; subsequence ( s ) ; System . out . println ( st ) ; } }

Accumulator variables: i, j, k
Iterator variables: i, j, k
Class/struct names: Subsequence
Java program:
class GFG { static void printSubSeqRec ( String str , int n , int index , String curr ) { if ( index == n ) { return ; } if ( curr != null && ! curr . trim ( ) . isEmpty ( ) ) { System . out . println ( curr ) ; } for ( int i = index + 1 ; i < n ; i ++ ) { curr += str . charAt ( i ) ; printSubSeqRec ( str , n , i , curr ) ; curr = curr . substring ( 0 , curr . length ( ) - 1 ) ; } } static void printSubSeq ( String str ) { int index = - 1 ; String curr = " " ; printSubSeqRec ( str , str . length ( ) , index , curr ) ; } public static void main ( String [ ] args ) { String str = " cab " ; printSubSeq ( str ) ; } }

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