dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
import java . io . * ; import java . util . * ; class GFG { static int findCount0th ( int [ ] arr , int N , int K ) { int oddsum = 0 , evensum = 0 ; for ( int i = 1 ; i < N ; i += 2 ) { oddsum += arr [ i ] ; } for ( int i = 2 ; i < N ; i += 2 ) { evensum += arr [ i ] ; } if ( Math . abs ( oddsum - evensum ) == K ) return 1 ; else return 0 ; } static int findCount1st ( int [ ] arr , int N , int K ) { int evensum = arr [ 0 ] , oddsum = 0 ; for ( int i = 3 ; i < N ; i += 2 ) { evensum += arr [ i ] ; } for ( int i = 2 ; i < N ; i += 2 ) { oddsum += arr [ i ] ; } if ( Math . abs ( oddsum - evensum ) == K ) return 1 ; else return 0 ; } static int countTimes ( int [ ] arr , int K ) { int N = ( int ) arr . length ; if ( N == 1 ) return 1 ; if ( N < 3 ) return 0 ; if ( N == 3 ) { int cnt = 0 ; cnt += ( Math . abs ( arr [ 0 ] - arr [ 1 ] ) == K ? 1 : 0 ) + ( Math . abs ( arr [ 2 ] - arr [ 1 ] ) == K ? 1 : 0 ) + ( Math . abs ( arr [ 0 ] - arr [ 2 ] ) == K ? 1 : 0 ) ; return cnt ; } int [ ] prefix = new int [ N + 2 ] ; int [ ] suffix = new int [ N + 2 ] ; Arrays . fill ( prefix , 0 ) ; Arrays . fill ( suffix , 0 ) ; prefix [ 0 ] = arr [ 0 ] ; prefix [ 1 ] = arr [ 1 ] ; suffix [ N - 1 ] = arr [ N - 1 ] ; suffix [ N - 2 ] = arr [ N - 2 ] ; for ( int i = 2 ; i < N ; i += 2 ) { prefix [ i ] = arr [ i ] + prefix [ i - 2 ] ; } for ( int i = 3 ; i < N ; i += 2 ) { prefix [ i ] = arr [ i ] + prefix [ i - 2 ] ; } for ( int i = N - 3 ; i >= 0 ; i -= 2 ) { suffix [ i ] = arr [ i ] + suffix [ i + 2 ] ; } for ( int i = N - 4 ; i >= 0 ; i -= 2 ) { suffix [ i ] = arr [ i ] + suffix [ i + 2 ] ; } int count = 0 ; for ( int i = 2 ; i < N ; i ++ ) { if ( Math . abs ( prefix [ i - 1 ] + suffix [ i + 2 ] - prefix [ i - 2 ] - suffix [ i + 1 ] ) == K ) { count ++ ; } } count += findCount0th ( arr , N , K ) ; count += findCount1st ( arr , N , K ) ; return count ; } public static void main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 4 , 5 , 6 } ; int K = 2 ; System . out . println ( countTimes ( arr , K ) ) ; } }

Index/key variables: i
Accumulator variables: cnt, count, evensum, i, oddsum
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int N , M ; static int [ ] [ ] mat ; static int row , col , start , flag ; static void fillMatrix ( int sizeOfpart , int noOfPart , int m ) { for ( int i = 0 ; i < noOfPart ; ++ i ) { int count = 0 ; while ( count < sizeOfpart ) { mat [ row ] [ col ] = start ; if ( col == m - 1 && flag == 1 ) { row ++ ; col = m ; flag = 0 ; } else if ( col == 0 && flag == 0 ) { row ++ ; col = - 1 ; flag = 1 ; } if ( flag == 1 ) { col ++ ; } else { col -- ; } count ++ ; } start ++ ; } } static void findMatrix ( int k ) { mat = new int [ M ] [ N ] ; row = 0 ; col = 0 ; int size = ( N * M ) / k ; int rem = ( N * M ) % k ; start = 1 ; flag = 1 ; fillMatrix ( size + 1 , rem , M ) ; fillMatrix ( size , k - rem , M ) ; } static void printMatrix ( ) { for ( int i = 0 ; i < N ; ++ i ) { for ( int j = 0 ; j < M ; ++ j ) { System . out . print ( mat [ i ] [ j ] + " ▁ " ) ; } System . out . println ( ) ; } } public static void main ( String [ ] args ) { N = 5 ; M = 5 ; int K = 6 ; findMatrix ( K ) ; printMatrix ( ) ; } }

Index/key variables: M, N, col, i, j, row
Accumulator variables: col, count, row, start
Iterator variables: i, j
Class/struct names: GFG
Java program:
class GFG { static String changeString ( String S ) { char [ ] s = S . toCharArray ( ) ; int N = ( int ) S . length ( ) ; if ( s [ 0 ] == ' ? ' ) { s [ 0 ] = ' a ' ; if ( s [ 0 ] == s [ 1 ] ) { s [ 0 ] ++ ; } } for ( int i = 1 ; i < N - 1 ; i ++ ) { if ( s [ i ] == ' ? ' ) { s [ i ] = ' a ' ; if ( s [ i ] == s [ i - 1 ] ) { s [ i ] ++ ; } if ( s [ i ] == s [ i + 1 ] ) { s [ i ] ++ ; } if ( s [ i ] == s [ i - 1 ] ) { s [ i ] ++ ; } } } if ( s [ N - 1 ] == ' ? ' ) { s [ N - 1 ] = ' a ' ; if ( s [ N - 1 ] == s [ N - 2 ] ) { s [ N - 1 ] ++ ; } } String ans = " " ; for ( int i = 0 ; i < s . length ; i ++ ) { ans += s [ i ] ; } return ans ; } public static void main ( String [ ] args ) { String S = " ? a ? a " ; System . out . print ( changeString ( S ) ) ; } }

Index/key variables: i
Accumulator variables: ans, i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int checkReverseBitonic ( String s ) { int i , j ; for ( i = 1 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) < s . charAt ( i - 1 ) ) continue ; if ( s . charAt ( i ) >= s . charAt ( i - 1 ) ) break ; } if ( i == s . length ( ) - 1 ) return 1 ; for ( j = i + 1 ; j < s . length ( ) ; j ++ ) { if ( s . charAt ( j ) > s . charAt ( j - 1 ) ) continue ; if ( s . charAt ( j ) <= s . charAt ( j - 1 ) ) break ; } i = j ; if ( i != s . length ( ) ) return 0 ; return 1 ; } public static void main ( String [ ] args ) { String s = " abcdwef " ; if ( checkReverseBitonic ( s ) == 1 ) System . out . println ( " YES " ) ; else System . out . println ( " NO " ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
class GFG { static int smallestNum ( int N ) { float x = ( float ) ( Math . pow ( 10 , ( N - 1 ) / 2.0 ) ) ; return ( int ) ( Math . ceil ( x ) ) ; } public static void main ( String [ ] args ) { int N = 4 ; System . out . print ( smallestNum ( N ) ) ; } }

Class/struct names: GFG
Java program:
class GFG { public static int countKCountdown ( int arr [ ] , int N , int K ) { int flag = - 1 ; int count = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( arr [ i ] == K ) flag = K ; if ( arr [ i ] == flag ) flag -- ; else flag = - 1 ; if ( flag == 0 ) count ++ ; } return count ; } public static void main ( String [ ] args ) { int N = 8 ; int K = 3 ; int arr [ ] = { 4 , 3 , 2 , 1 , 5 , 3 , 2 , 1 } ; System . out . print ( countKCountdown ( arr , N , K ) ) ; } }

Index/key variables: i
Accumulator variables: count, flag, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static String decToHexa ( int n ) { char [ ] hexaDeciNum = new char [ 2 ] ; int i = 0 ; while ( n != 0 ) { int temp = 0 ; temp = n % 16 ; if ( temp < 10 ) { hexaDeciNum [ i ] = ( char ) ( temp + 48 ) ; i ++ ; } else { hexaDeciNum [ i ] = ( char ) ( temp + 55 ) ; i ++ ; } n = n / 16 ; } String hexCode = " " ; if ( i == 2 ) { hexCode += hexaDeciNum [ 0 ] ; hexCode += hexaDeciNum [ 1 ] ; } else if ( i == 1 ) { hexCode = "0" ; hexCode += hexaDeciNum [ 0 ] ; } else if ( i == 0 ) hexCode = "00" ; return hexCode ; } static String convertRGBtoHex ( int R , int G , int B ) { if ( ( R >= 0 && R <= 255 ) && ( G >= 0 && G <= 255 ) && ( B >= 0 && B <= 255 ) ) { String hexCode = " # " ; hexCode += decToHexa ( R ) ; hexCode += decToHexa ( G ) ; hexCode += decToHexa ( B ) ; return hexCode ; } else return " - 1" ; } public static void main ( String [ ] args ) { int R = 0 , G = 0 , B = 0 ; System . out . print ( convertRGBtoHex ( R , G , B ) + "NEW_LINE"); R = 255 ; G = 255 ; B = 255 ; System . out . print ( convertRGBtoHex ( R , G , B ) + "NEW_LINE"); R = 25 ; G = 56 ; B = 123 ; System . out . print ( convertRGBtoHex ( R , G , B ) + "NEW_LINE"); R = 2 ; G = 3 ; B = 4 ; System . out . print ( convertRGBtoHex ( R , G , B ) + "NEW_LINE"); R = 255 ; G = 255 ; B = 256 ; System . out . print ( convertRGBtoHex ( R , G , B ) + "NEW_LINE"); } }

Index/key variables: i
Accumulator variables: hexCode, i
Class/struct names: GFG
Java program:
import java . util . * ; public class GFG { public static void getStrings ( String str , String [ ] arr ) { for ( int i = 0 ; i < arr . length ; i ++ ) { if ( check ( arr [ i ] , str ) ) { System . out . print ( arr [ i ] + " ▁ " ) ; } } } public static boolean check ( String s , String str ) { char [ ] chars = s . toCharArray ( ) ; for ( char c : chars ) { if ( ! str . contains ( String . valueOf ( c ) ) ) { return false ; } } for ( int i = 0 ; i < chars . length - 1 ; i ++ ) { if ( chars [ i ] == chars [ i + 1 ] ) { return false ; } } return true ; } public static void main ( String [ ] args ) { String str = " ABCD " ; String [ ] arr = { " AABCDA " , " ABCDZADC " , " ABCDBCA " , " ABCDABDCA " } ; getStrings ( str , arr ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: c, i
Class/struct names: GFG
Java program:
class GFG { static void q1 ( String s , int i ) { if ( i == s . length ( ) ) { System . out . println ( " Yes " ) ; return ; } if ( s . charAt ( i ) == ' a ' ) q1 ( s , i + 1 ) ; else q2 ( s , i + 1 ) ; } static void q2 ( String s , int i ) { if ( i == s . length ( ) ) { System . out . println ( " No " ) ; return ; } if ( s . charAt ( i ) == ' a ' ) q1 ( s , i + 1 ) ; else q2 ( s , i + 1 ) ; } static void q3 ( String s , int i ) { if ( i == s . length ( ) ) { System . out . println ( " Yes " ) ; return ; } if ( s . charAt ( i ) == ' a ' ) q4 ( s , i + 1 ) ; else q3 ( s , i + 1 ) ; } static void q4 ( String s , int i ) { if ( i == s . length ( ) ) { System . out . println ( " No " ) ; return ; } if ( s . charAt ( i ) == ' a ' ) q4 ( s , i + 1 ) ; else q3 ( s , i + 1 ) ; } static void q0 ( String s , int i ) { if ( i == s . length ( ) ) { System . out . println ( " No " ) ; return ; } if ( s . charAt ( i ) == ' a ' ) q1 ( s , i + 1 ) ; else q3 ( s , i + 1 ) ; } public static void main ( String [ ] args ) { String s = " abbaabb " ; q0 ( s , 0 ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void prefix ( char [ ] str ) { int k = 1 , j ; int n = str . length ; Vector < Integer > g = new Vector < > ( ) ; int flag = 0 ; for ( int i = 1 ; i < n ; i ++ ) { if ( str [ i ] == str [ 0 ] ) { g . add ( i ) ; flag = 1 ; } } if ( flag == 0 ) { System . out . println ( String . valueOf ( str ) ) ; } else { int len = g . size ( ) ; while ( k < g . get ( 0 ) ) { int cnt = 0 ; for ( j = 0 ; j < len ; j ++ ) { if ( ( g . get ( j ) + k ) < n && str [ g . get ( j ) + k ] == str [ k ] ) { cnt ++ ; } } if ( cnt == len ) { k ++ ; } else { break ; } } for ( int i = 0 ; i < k ; i ++ ) { System . out . print ( str [ i ] ) ; } System . out . println ( ) ; } } public static void main ( String args [ ] ) { String str = " abcab " ; prefix ( str . toCharArray ( ) ) ; } }

Index/key variables: i, k
Accumulator variables: cnt, i, j, k
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . Vector ; class GFG { static void printPermutation ( int N , int K ) { Vector < Integer > res = new Vector < > ( ) ; int l = 1 , r = N , flag = 0 ; for ( int i = 0 ; i < K ; i ++ ) { if ( flag == 0 ) { res . add ( l ) ; l ++ ; } else { res . add ( r ) ; r -- ; } flag ^= 1 ; } if ( flag != 1 ) { for ( int i = r ; i >= l ; i -- ) { res . add ( i ) ; } } else { for ( int i = l ; i <= r ; i ++ ) { res . add ( i ) ; } } for ( Integer i : res ) { System . out . print ( i + " ▁ " ) ; } } public static void main ( String [ ] args ) { int N = 10 , K = 4 ; printPermutation ( N , K ) ; } }

Accumulator variables: flag, i, l, r
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { public static int fact ( int N ) { int i , product = 1 ; for ( i = 1 ; i <= N ; i ++ ) product = product * i ; return product ; } public static int nthTerm ( int N ) { return ( N * N ) * fact ( N ) ; } public static void main ( String [ ] args ) { System . out . println ( nthTerm ( N ) ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
public class Main { public final static int d = 256 ; static void search ( String pat , String txt , int q ) { int M = pat . length ( ) ; int N = txt . length ( ) ; int i , j ; int h = 1 ; for ( i = 0 ; i < M - 1 ; i ++ ) h = ( h * d ) % q ; for ( i = 0 ; i < M ; i ++ ) { p = ( d * p + pat . charAt ( i ) ) % q ; t = ( d * t + txt . charAt ( i ) ) % q ; } for ( i = 0 ; i <= N - M ; i ++ ) { if ( p == t ) { for ( j = 0 ; j < M ; j ++ ) { if ( txt . charAt ( i + j ) != pat . charAt ( j ) ) break ; } if ( j == M ) System . out . println ( " Pattern ▁ found ▁ at ▁ index ▁ " + i ) ; } if ( i < N - M ) { t = ( d * ( t - txt . charAt ( i ) * h ) + txt . charAt ( i + M ) ) % q ; if ( t < 0 ) t = ( t + q ) ; } } } public static void main ( String [ ] args ) { String txt = " GEEKS ▁ FOR ▁ GEEKS " ; String pat = " GEEK " ; int q = 101 ; search ( pat , txt , q ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: Main
Java program:
import java . util . ArrayList ; import java . util . Arrays ; class GFG { public static int MAXN = 100001 ; public static int [ ] spf = new int [ MAXN ] ; public static void sieve ( ) { spf [ 1 ] = 1 ; for ( int i = 2 ; i < MAXN ; i ++ ) spf [ i ] = i ; for ( int i = 4 ; i < MAXN ; i += 2 ) spf [ i ] = 2 ; for ( int i = 3 ; i * i < MAXN ; i ++ ) { if ( spf [ i ] == i ) { for ( int j = i * i ; j < MAXN ; j += i ) { if ( spf [ j ] == j ) spf [ j ] = i ; } } } } public static ArrayList < Integer > getFactorization ( int x ) { ArrayList < Integer > ret = new ArrayList < Integer > ( ) ; while ( x != 1 ) { ret . add ( spf [ x ] ) ; int value = spf [ x ] ; while ( x % value == 0 ) x = x / value ; } return ret ; } public static String flipString ( String S , int arr [ ] , int M ) { sieve ( ) ; int [ ] frequency = new int [ MAXN ] ; Arrays . fill ( frequency , 0 ) ; for ( int i = 0 ; i < M ; i ++ ) { ArrayList < Integer > primeFactors = getFactorization ( arr [ i ] ) ; for ( int factors : primeFactors ) { frequency [ factors ] ++ ; frequency [ factors ] %= 2 ; } } int N = S . length ( ) ; for ( int i = 0 ; i < MAXN ; i ++ ) { if ( ( frequency [ i ] & 1 ) > 0 ) { for ( int j = i ; j <= N ; j += i ) { S = S . substring ( 0 , j - 1 ) + ( S . charAt ( j - 1 ) == '1' ? '0' : '1' ) + S . substring ( j ) ; } } } return S ; } public static void main ( String args [ ] ) { String S = "000000" ; int arr [ ] = { 2 , 4 , 6 } ; int M = arr . length ; System . out . println ( flipString ( S , arr , M ) ) ; } }

Index/key variables: MAXN, factors, i, j, x
Accumulator variables: i, j
Iterator variables: factors, i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void isOnesGreater ( String S , int N ) { char [ ] st = new char [ S . length ( ) ] ; for ( int i = 0 ; i < S . length ( ) ; i ++ ) { st [ i ] = S . charAt ( i ) ; } int cnt0 = 0 ; int cnt1 = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( st [ i ] == '1' ) cnt1 ++ ; else cnt0 ++ ; } for ( int i = 0 ; i < N ; i ++ ) { if ( st [ i ] == '1' ) { if ( i > 0 && st [ i - 1 ] == '0' ) { st [ i - 1 ] = ' _ ' ; cnt0 -- ; } else if ( i < N && st [ i + 1 ] == '0' ) { st [ i + 1 ] = ' _ ' ; cnt0 -- ; } } } if ( cnt1 > cnt0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } public static void main ( String args [ ] ) { String S = "01" ; int N = S . length ( ) ; isOnesGreater ( S , N ) ; } }

Index/key variables: i
Accumulator variables: cnt0, cnt1, i
Iterator variables: i
Class/struct names: GFG
Java program:
public class GFG { static void minOperation ( String S , int K , int N ) { int min = 0 ; int i ; for ( i = 0 ; i < N ; i ++ ) { if ( S . charAt ( i ) == '0' && i + K <= N ) { for ( int j = i ; j < i + K ; j ++ ) { if ( S . charAt ( j ) == '1' ) S = S . substring ( 0 , j ) + '0' + S . substring ( j + 1 ) ; else S = S . substring ( 0 , j ) + '1' + S . substring ( j + 1 ) ; } min ++ ; } } for ( i = 0 ; i < N ; i ++ ) { if ( S . charAt ( i ) == '0' ) break ; } if ( i == N ) System . out . println ( min ) ; else System . out . println ( - 1 ) ; } public static void main ( String [ ] args ) { String S = "00010110" ; int K = 3 ; int N = S . length ( ) ; minOperation ( S , K , N ) ; } }

Accumulator variables: i, j, min
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { static boolean validInsertionstring ( String S1 , String S2 ) { int N = S1 . length ( ) ; int M = S2 . length ( ) ; Stack < Character > st = new Stack < > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { st . push ( S1 . charAt ( i ) ) ; if ( S1 . charAt ( i ) == S2 . charAt ( M - 1 ) ) { int idx = M - 1 ; while ( idx >= 0 ) { if ( st . size ( ) == 0 ) { return false ; } char c = st . peek ( ) ; st . pop ( ) ; if ( c != S2 . charAt ( idx ) ) { return false ; } idx -- ; } } } if ( st . size ( ) > 0 ) { return false ; } else { return true ; } } public static void main ( String [ ] args ) { String S1 = " aabb " ; String S2 = " ab " ; if ( validInsertionstring ( S1 , S2 ) == true ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } }

Accumulator variables: i, idx
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . Arrays ; class GFG { static int MAX = 256 ; static boolean can_form_palindrome ( int [ ] arr , int n ) { String str = " " ; for ( int i = 0 ; i < n ; i ++ ) { str += arr [ i ] ; } int freq [ ] = new int [ MAX ] ; Arrays . fill ( freq , 0 ) ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { freq [ str . charAt ( i ) ] ++ ; } int count = 0 ; for ( int i = 0 ; i < MAX ; i ++ ) { if ( ( freq [ i ] & 1 ) != 0 ) { count ++ ; } if ( count > 1 ) { return false ; } } return true ; } public static void main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 3 , 1 , 2 } ; int n = arr . length ; if ( can_form_palindrome ( arr , n ) ) System . out . println ( " YES " ) ; else System . out . println ( " NO " ) ; } }

Index/key variables: MAX, i
Accumulator variables: count, i, str
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int minimumFlips ( String s ) { int n = s . length ( ) ; int cnt0 = count ( s , '0' ) ; int cnt1 = 0 ; int res = n - cnt0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( s . charAt ( i ) == '0' ) { cnt0 -= 1 ; } else if ( s . charAt ( i ) == '1' ) { res = Math . min ( res , cnt1 + cnt0 ) ; cnt1 ++ ; } } return res ; } private static int count ( String s , char c ) { int ans = 0 ; for ( char i : s . toCharArray ( ) ) if ( c == i ) ans ++ ; return ans ; } public static void main ( String [ ] args ) { String S = "000110" ; System . out . print ( minimumFlips ( S ) ) ; } }

Accumulator variables: ans, cnt0, cnt1, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static HashSet < String > presentSubString ( String s , int k ) { HashSet < String > st = new HashSet < String > ( ) ; int n = s . length ( ) ; for ( int i = 0 ; i < n ; i ++ ) { String s1 = " " ; for ( int j = 0 ; j < k && i + j < n ; j ++ ) { s1 += s . charAt ( i + j ) ; st . add ( s1 ) ; } } return st ; } static String smallestSubString ( String s , int k ) { HashSet < String > st = new HashSet < String > ( ) ; st = presentSubString ( s , k ) ; int index ; for ( int len = 1 ; len <= k ; len ++ ) { String t = " " ; for ( int i = 0 ; i < len ; i ++ ) t += ' a ' ; while ( true ) { if ( ! st . contains ( t ) ) { return t ; } index = len - 1 ; while ( index >= 0 && t . charAt ( index ) == ' z ' ) { t = t . substring ( 0 , index ) + ' a ' + t . substring ( index + 1 ) ; index -- ; } if ( index >= 0 ) t = t . substring ( 0 , index ) + ( char ) ( ( t . charAt ( index ) ) + 1 ) + t . substring ( index + 1 ) ; else break ; } } return " - 1" ; } public static void main ( String [ ] args ) { String s = " sdhaacbdefghijklmnopqrstuvwxyz " ; int K = 3 ; System . out . print ( smallestSubString ( s , K ) + "NEW_LINE"); } }

Accumulator variables: i, index, j, len, s1, t
Iterator variables: i, j, len
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int maximumK ( String S ) { int N = S . length ( ) ; int ans = N ; int flag = 0 ; for ( int i = 0 ; i < N - 1 ; i ++ ) { if ( S . charAt ( i ) != S . charAt ( i + 1 ) ) { flag = 1 ; ans = Math . min ( ans , Math . max ( i + 1 , N - i - 1 ) ) ; } } if ( flag == 0 ) return 0 ; return ans ; } public static void main ( String [ ] args ) { String S = "010" ; System . out . print ( maximumK ( S ) ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static void minimumTimeToConvertString ( String S , int N ) { int upper = 0 , lower = 0 ; for ( int i = 0 ; i < N ; i ++ ) { char c = S . charAt ( i ) ; if ( Character . isUpperCase ( c ) ) { upper ++ ; } else { lower ++ ; } } int moves = 0 ; if ( upper > N / 2 ) { int i = 0 ; while ( upper > N / 2 && i < N ) { if ( Character . isUpperCase ( S . charAt ( i ) ) ) { S = S . substring ( 0 , i ) + ( char ) ( S . charAt ( i ) + 32 ) + S . substring ( i + 1 ) ; moves ++ ; upper -- ; lower ++ ; } i ++ ; } } else if ( lower > N / 2 ) { int i = 0 ; while ( lower > N / 2 && i < N ) { if ( Character . isLowerCase ( S . charAt ( i ) ) ) { S = S . substring ( 0 , i ) + ( char ) ( S . charAt ( i ) - 32 ) + S . substring ( i + 1 ) ; moves ++ ; upper ++ ; lower -- ; } i ++ ; } } System . out . println ( moves ) ; System . out . println ( S ) ; } public static void main ( String [ ] args ) { String S = " AbcdEf " ; int N = S . length ( ) ; minimumTimeToConvertString ( S , N ) ; } }

Accumulator variables: i, lower, moves, upper
Iterator variables: i
Class/struct names: GFG
Java program:
public class GFG { static void zigzag ( String s , int rows ) { int interval = 2 * rows - 2 ; for ( int i = 0 ; i < rows ; i ++ ) { int step = interval - 2 * i ; for ( int j = i ; j < s . length ( ) ; j = j + interval ) { System . out . print ( s . charAt ( j ) ) ; if ( step > 0 && step < interval && step + j < s . length ( ) ) { for ( int k = 0 ; k < ( interval - rows - i ) ; k ++ ) System . out . print ( " ▁ " ) ; System . out . print ( s . charAt ( j + step ) ) ; for ( int k = 0 ; k < i - 1 ; k ++ ) System . out . print ( " ▁ " ) ; } else { for ( int k = 0 ; k < ( interval - rows ) ; k ++ ) System . out . print ( " ▁ " ) ; } } System . out . println ( ) ; } } public static void main ( String args [ ] ) { String s = "123456789ABCDEFGHIJKLM " + " NOPQRSTUVWXYZabcdefghi " + " jklmnopqrstuvwxyz " ; int rows = 9 ; zigzag ( s , rows ) ; } }

Accumulator variables: i, k
Iterator variables: i, j, k
Class/struct names: GFG
Java program:
import java . util . * ; import java . lang . * ; class GFG { static int subString ( String s , int n ) { Map < Integer , Integer > hash = new HashMap < > ( ) ; hash . put ( 0 , 1 ) ; int pre = 0 ; int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { pre ^= ( 1 << ( int ) ( s . charAt ( i ) - 97 ) ) ; count += hash . getOrDefault ( pre , 0 ) ; hash . put ( pre , hash . getOrDefault ( pre , 0 ) + 1 ) ; } return count ; } public static void main ( String [ ] args ) { String S = " abbaa " ; int N = S . length ( ) ; System . out . print ( subString ( S , N ) ) ; } }

Accumulator variables: count, i, pre
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void atleastkDistinctChars ( String s , int k ) { int n = s . length ( ) ; Map < Character , Integer > mp = new HashMap < > ( ) ; int begin = 0 , end = 0 ; int ans = 0 ; while ( end < n ) { char c = s . charAt ( end ) ; mp . put ( c , mp . getOrDefault ( c , 0 ) + 1 ) ; end ++ ; while ( mp . size ( ) >= k ) { char pre = s . charAt ( begin ) ; mp . put ( pre , mp . getOrDefault ( pre , 0 ) - 1 ) ; if ( mp . get ( pre ) == 0 ) { mp . remove ( pre ) ; } ans += s . length ( ) - end + 1 ; begin ++ ; } } System . out . println ( ans ) ; } public static void main ( String [ ] args ) { String S = " abcca " ; int K = 3 ; atleastkDistinctChars ( S , K ) ; } }

Accumulator variables: ans, begin, end
Class/struct names: GFG
Java program:
import java . io . * ; import java . lang . * ; import java . util . * ; class GFG { static void canSplit ( String S ) { int frequency [ ] = new int [ 26 ] ; int cnt_singles = 0 ; int k = 0 ; for ( int i = 0 ; i < S . length ( ) ; i ++ ) frequency [ S . charAt ( i ) - ' a ' ] ++ ; int odd = 0 , eve = 0 ; for ( int i = 0 ; i < 26 ; i ++ ) { if ( frequency [ i ] != 0 ) { odd += ( frequency [ i ] & 1 ) ; eve += frequency [ i ] / 2 ; } } if ( eve >= odd ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } public static void main ( String [ ] args ) { String S = " aaabbbccc " ; canSplit ( S ) ; } }

Index/key variables: i
Accumulator variables: eve, i, odd
Iterator variables: i
Class/struct names: GFG