dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
import java . io . * ; class GFG { static boolean isPrime ( int num ) { boolean flag = false ; if ( num > 1 ) { for ( int i = 2 ; i < num ; i ++ ) { if ( ( num % i ) == 0 ) { flag = true ; break ; } } } if ( flag ) return false ; else return true ; } static int order ( int x ) { int n = 0 ; while ( x != 0 ) { n = n + 1 ; x = x / 10 ; } return n ; } static boolean isArmstrong ( int x ) { int n = order ( x ) ; int temp = x ; int sum1 = 0 ; while ( temp != 0 ) { int r = temp % 10 ; sum1 = sum1 + ( int ) ( Math . pow ( r , n ) ) ; temp = temp / 10 ; } return ( sum1 == x ) ; } static int count_armstrong ( String [ ] li ) { int c = 0 ; for ( String ele : li ) { int val = 0 ; for ( char che : ele . toCharArray ( ) ) val += che ; if ( isArmstrong ( val ) ) c += 1 ; } return c ; } static int count_prime ( String [ ] li ) { int c = 0 ; for ( String ele : li ) { int val = 0 ; for ( char che : ele . toCharArray ( ) ) val += che ; if ( isPrime ( val ) ) c += 1 ; } return c ; } public static void main ( String [ ] args ) { String [ ] arr = { " geeksforgeeks " , " a " , " computer " , " science " , " portal " , " for " , " geeks " } ; System . out . println ( " Number ▁ of ▁ Armstrong ▁ Strings ▁ are : ▁ " + count_armstrong ( arr ) ) ; System . out . println ( " Number ▁ of ▁ Prime ▁ Strings ▁ are : ▁ " + count_prime ( arr ) ) ; } }

Accumulator variables: c, i, val
Iterator variables: che, ele, i
Boolean variables: flag
Class/struct names: GFG
Java program:
import java . io . * ; import java . lang . * ; import java . util . * ; class GFG { static void findMinimumCost ( String s , int N ) { int count_1 = 0 , count_0 = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( s . charAt ( i ) == '1' ) count_1 ++ ; else count_0 ++ ; } int k = Math . abs ( count_0 - count_1 ) ; if ( count_1 == N count_0 == N ) System . out . println ( - 1 ) ; else System . out . println ( k / 2 ) ; } public static void main ( String [ ] args ) { String S = "110110" ; int N = S . length ( ) ; findMinimumCost ( S , N ) ; } }

Accumulator variables: count_0, count_1, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . HashMap ; import java . util . Map ; class GFG { static void findMinimumTime ( String S , int N , int K ) { if ( N == 0 ) { System . out . println ( 0 ) ; return ; } int maxfreq = Integer . MIN_VALUE ; char maxchar = ' ▁ ' ; HashMap < Character , Integer > um = new HashMap < > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { um . put ( S . charAt ( i ) , um . getOrDefault ( S . charAt ( i ) , 0 ) + 1 ) ; if ( um . get ( S . charAt ( i ) ) > maxfreq ) { maxfreq = um . get ( S . charAt ( i ) ) ; maxchar = S . charAt ( i ) ; } } int emptySlots = ( maxfreq - 1 ) * K ; for ( Map . Entry < Character , Integer > it : um . entrySet ( ) ) { if ( it . getKey ( ) == maxchar ) continue ; emptySlots -= Math . min ( it . getValue ( ) , maxfreq - 1 ) ; } int ans = N + Math . max ( 0 , emptySlots ) ; System . out . println ( ans ) ; } public static void main ( String [ ] args ) { String S = " AAABBB " ; int K = 2 ; int N = S . length ( ) ; findMinimumTime ( S , N , K ) ; } }

Accumulator variables: emptySlots, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static void canMakeEqual ( String S ) { int N = S . length ( ) ; int weightOfString = 0 ; for ( int i = 0 ; i < N ; i ++ ) { weightOfString += S . charAt ( i ) - ' a ' + 1 ; } if ( weightOfString % N == 0 ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } public static void main ( String [ ] args ) { String S = " beb " ; canMakeEqual ( S ) ; } }

Accumulator variables: i, weightOfString
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . lang . * ; import java . util . * ; public class GFG { static void addFrequencyToCharacter ( String Str ) { int frequency [ ] = new int [ 26 ] ; int N = Str . length ( ) ; char S [ ] = Str . toCharArray ( ) ; for ( int i = 0 ; i < N ; i ++ ) { frequency [ S [ i ] - ' a ' ] += 1 ; } for ( int i = 0 ; i < N ; i ++ ) { int add = frequency [ S [ i ] - ' a ' ] % 26 ; if ( ( int ) ( S [ i ] ) + add <= ( int ) ( ' z ' ) ) S [ i ] = ( char ) ( ( int ) ( S [ i ] ) + add ) ; else { add = ( ( int ) ( S [ i ] ) + add ) - ( ( int ) ( ' z ' ) ) ; S [ i ] = ( char ) ( ( int ) ( ' a ' ) + add - 1 ) ; } } System . out . println ( new String ( S ) ) ; } public static void main ( String [ ] args ) { String S = " geeksforgeeks " ; addFrequencyToCharacter ( S ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . lang . * ; import java . util . * ; public class GFG { static int minLength ( String S ) { Stack < Character > st = new Stack < > ( ) ; for ( char ch : S . toCharArray ( ) ) { if ( st . isEmpty ( ) ) st . push ( ch ) ; else { char top = st . peek ( ) ; if ( Math . abs ( ch - top ) == 1 ) st . pop ( ) ; else { st . push ( ch ) ; } } } return st . size ( ) ; } public static void main ( String [ ] args ) { String S = "12213" ; System . out . println ( minLength ( S ) ) ; } }

Iterator variables: ch
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void findMinimumTime ( String tasks , int K ) { Map < Character , Integer > map = new HashMap < > ( ) ; int curr_time = 0 ; for ( char c : tasks . toCharArray ( ) ) { if ( map . containsKey ( c ) ) { if ( curr_time - map . get ( c ) <= K ) { curr_time += K - ( curr_time - map . get ( c ) ) + 1 ; } } map . put ( c , curr_time ) ; curr_time ++ ; } System . out . println ( curr_time ) ; } public static void main ( String [ ] args ) { String S = " ABACCA " ; int K = 2 ; findMinimumTime ( S , K ) ; } }

Accumulator variables: curr_time
Iterator variables: c
Class/struct names: GFG
Java program:
import java . util . Stack ; public class GFG { static void checkforSubsequence ( String S , String target ) { Stack < Character > s = new Stack < > ( ) ; for ( int i = 0 ; i < target . length ( ) ; i ++ ) { s . push ( target . charAt ( i ) ) ; } for ( int i = ( int ) S . length ( ) - 1 ; i >= 0 ; i -- ) { if ( s . empty ( ) ) { System . out . println ( " Yes " ) ; return ; } if ( S . charAt ( i ) == s . peek ( ) ) { s . pop ( ) ; } } if ( s . empty ( ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } public static void main ( String [ ] args ) { String S = " KOTTAYAM " ; String target = " KOTA " ; checkforSubsequence ( S , target ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . lang . * ; import java . util . * ; class GFG { static String digits = "0123456789" , sign = " + - " ; static String dot = " . " , ex = " eE " ; static int dfa [ ] [ ] = new int [ 11 ] [ 5 ] ; static void makeDFA ( ) { dfa [ 0 ] [ 0 ] = 1 ; dfa [ 1 ] [ 0 ] = 1 ; dfa [ 1 ] [ 2 ] = 3 ; dfa [ 1 ] [ 3 ] = 2 ; dfa [ 1 ] [ 4 ] = 6 ; dfa [ 3 ] [ 0 ] = 4 ; dfa [ 4 ] [ 0 ] = 4 ; dfa [ 4 ] [ 3 ] = 5 ; dfa [ 4 ] [ 4 ] = 6 ; dfa [ 6 ] [ 0 ] = 8 ; dfa [ 6 ] [ 1 ] = 7 ; dfa [ 7 ] [ 0 ] = 8 ; dfa [ 8 ] [ 0 ] = 8 ; dfa [ 8 ] [ 3 ] = 9 ; } static void buildDFA ( ) { for ( int i = 0 ; i < 11 ; i ++ ) for ( int j = 0 ; j < 5 ; j ++ ) dfa [ i ] [ j ] = 10 ; makeDFA ( ) ; } static void checkDFA ( String s ) { buildDFA ( ) ; int currentstate = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( digits . indexOf ( s . charAt ( i ) ) != - 1 ) currentstate = dfa [ currentstate ] [ 0 ] ; else if ( sign . indexOf ( s . charAt ( i ) ) != - 1 ) currentstate = dfa [ currentstate ] [ 1 ] ; else if ( dot . indexOf ( s . charAt ( i ) ) != - 1 ) currentstate = dfa [ currentstate ] [ 2 ] ; else if ( ex . indexOf ( s . charAt ( i ) ) != - 1 ) currentstate = dfa [ currentstate ] [ 4 ] ; else currentstate = dfa [ currentstate ] [ 3 ] ; } if ( currentstate == 1 currentstate == 4 currentstate == 8 ) { System . out . println ( " Unsigned ▁ integer " ) ; } else { System . out . println ( " Not ▁ an ▁ unsigned ▁ integer " ) ; } } public static void main ( String [ ] args ) { String S = "1729" ; checkDFA ( S ) ; } }

Index/key variables: currentstate, i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . io . * ; import java . lang . * ; import java . util . * ; public class GFG { static void printSentence ( String S ) { String nums [ ] = { " " , " " , " ABC " , " DEF " , " GHI " , " JKL " , " MNO " , " PQRS " , " TUV " , " WXYZ " } ; char str [ ] = S . toCharArray ( ) ; int i = 0 ; while ( i < str . length ) { if ( str [ i ] == ' . ' ) { i ++ ; continue ; } int count = 0 ; while ( i + 1 < str . length && str [ i ] == str [ i + 1 ] ) { if ( count == 2 && ( ( str [ i ] >= '2' && str [ i ] <= '6' ) || ( str [ i ] == '8' ) ) ) break ; else if ( count == 3 && ( str [ i ] == '7' str [ i ] == '9' ) ) break ; count ++ ; i ++ ; if ( i == str . length ) break ; } if ( str [ i ] == '7' str [ i ] == '9' ) { System . out . print ( nums [ str [ i ] - 48 ] . charAt ( count % 4 ) ) ; } else { System . out . print ( nums [ str [ i ] - 48 ] . charAt ( count % 3 ) ) ; } i ++ ; } } public static void main ( String [ ] args ) { String str = "234" ; printSentence ( str ) ; } }

Index/key variables: i
Accumulator variables: count, i
Class/struct names: GFG
Java program:
import java . io . * ; import java . lang . * ; import java . util . * ; public class GFG { static String getString ( int N ) { String ans = " " ; while ( N >= 26 ) { ans += ' z ' ; N -= 26 ; } ans += ( char ) ( N + ' a ' - 1 ) ; return ans ; } public static void main ( String [ ] args ) { int N = 30 ; System . out . print ( getString ( N ) ) ; } }

Accumulator variables: N, ans
Class/struct names: GFG
Java program:
import java . io . * ; import java . lang . * ; import java . util . * ; class GFG { static void countSamePrefixSuffix ( String s , int n ) { String prefix = " " ; for ( int i = 0 ; i < n - 1 ; i ++ ) { prefix += s . charAt ( i ) ; String suffix = s . substring ( n - 1 - i , n ) ; if ( prefix . equals ( suffix ) ) { System . out . print ( prefix . length ( ) + " ▁ " ) ; } } } public static void main ( String [ ] args ) { String S = " ababababab " ; int N = S . length ( ) ; countSamePrefixSuffix ( S , N ) ; } }

Accumulator variables: i, prefix
Iterator variables: i
Class/struct names: GFG
Java program:
import java . lang . * ; import java . util . * ; class GFG { static void countStringPairs ( String a [ ] , int n ) { int ans = 0 ; Map < String , Integer > s = new HashMap < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { s . put ( a [ i ] , s . getOrDefault ( a [ i ] , 0 ) ) ; } for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { StringBuilder p = new StringBuilder ( a [ i ] ) ; StringBuilder q = new StringBuilder ( a [ j ] ) ; if ( p . charAt ( 0 ) != q . charAt ( 0 ) ) { char t = p . charAt ( 0 ) ; p . setCharAt ( 0 , q . charAt ( 0 ) ) ; q . setCharAt ( 0 , t ) ; if ( ! s . containsKey ( p . toString ( ) ) && ! s . containsKey ( q . toString ( ) ) ) { ans ++ ; } } } } System . out . println ( ans ) ; } public static void main ( String [ ] args ) { String arr [ ] = { " good " , " bad " , " food " } ; int N = arr . length ; countStringPairs ( arr , N ) ; } }

Index/key variables: i, j
Accumulator variables: ans, i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . io . * ; import java . lang . * ; import java . util . * ; class GFG { static void minimumMoves ( String s , int n , int k ) { if ( n % 2 == 1 ) { System . out . println ( " No " ) ; return ; } int countOpen = 0 , countClose = 0 ; for ( char ch : s . toCharArray ( ) ) if ( ch == ' ( ' ) countOpen ++ ; else if ( ch == ' ) ' ) countClose ++ ; if ( countOpen != countClose ) { System . out . println ( " No " ) ; return ; } int ans = 0 ; int cnt = 0 ; for ( int i = 0 ; i < n ; ++ i ) { if ( s . charAt ( i ) == ' ( ' ) ++ cnt ; else { -- cnt ; if ( cnt < 0 ) { cnt = 0 ; ++ ans ; } } } if ( ans <= k ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } public static void main ( String [ ] args ) { String S = " ) ( " ; int K = 1 ; minimumMoves ( S , S . length ( ) , K ) ; } }

Accumulator variables: countClose, countOpen
Iterator variables: ch, i
Class/struct names: GFG
Java program:
class GFG { static int findRandom ( ) { int num = ( 1 + ( int ) ( Math . random ( ) * 100 ) ) % 2 ; return num ; } static void generateBinaryString ( int N ) { String S = " " ; for ( int i = 0 ; i < N ; i ++ ) { int x = findRandom ( ) ; S = S + String . valueOf ( x ) ; } System . out . println ( S ) ; } public static void main ( String [ ] args ) { int N = 7 ; generateBinaryString ( N ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . lang . * ; import java . util . * ; class GFG { static void checkPalindrome ( String s ) { int a [ ] = new int [ 26 ] ; int o = 0 , e = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) a [ s . charAt ( i ) - ' a ' ] ++ ; for ( int i = 0 ; i < 26 ; i ++ ) { if ( a [ i ] == 1 ) o ++ ; else if ( a [ i ] % 2 == 0 && a [ i ] != 0 ) e += ( a [ i ] / 2 ) ; } if ( e >= o ) System . out . println ( " Yes " ) ; else { o = o - e ; for ( int i = 0 ; i < 26 ; i ++ ) { if ( o <= 0 ) break ; if ( o > 0 && a [ i ] % 2 == 1 && a [ i ] > 2 ) { int k = o ; o = o - a [ i ] / 2 ; if ( o > 0 2 * k + 1 == a [ i ] ) { o ++ ; a [ i ] = 1 ; } } } if ( o <= 0 ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } } public static void main ( String [ ] args ) { String S = " abbbaddzcz " ; checkPalindrome ( S ) ; } }

Index/key variables: i
Accumulator variables: e, i, o
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static void maximumTime ( String str ) { char [ ] s = str . toCharArray ( ) ; if ( s [ 0 ] == ' _ ' ) { if ( ( s [ 1 ] == ' _ ' ) || ( s [ 1 ] >= '0' && s [ 1 ] < '4' ) ) { s [ 0 ] = '2' ; } else { s [ 0 ] = '1' ; } } if ( s [ 1 ] == ' _ ' ) { if ( s [ 0 ] == '2' ) { s [ 1 ] = '3' ; } else { s [ 1 ] = '9' ; } } if ( s [ 3 ] == ' _ ' ) { s [ 3 ] = '5' ; } if ( s [ 4 ] == ' _ ' ) { s [ 4 ] = '9' ; } for ( int i = 0 ; i < s . length ; i ++ ) System . out . print ( s [ i ] ) ; } static public void main ( String [ ] args ) { String S = "0 _ : 4 _ " ; maximumTime ( S ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . lang . * ; import java . util . * ; class GFG { static void nearestPowerOfTwoUtil ( HashMap < Character , Integer > freq ) { for ( char key : freq . keySet ( ) ) { System . out . print ( key + " ▁ - > ▁ " ) ; int lg = ( int ) ( Math . log ( freq . get ( key ) / Math . log ( 2 ) ) ) ; int a = ( int ) Math . pow ( 2 , lg ) ; int b = ( int ) Math . pow ( 2 , lg + 1 ) ; if ( ( freq . get ( key ) - a ) < ( b - freq . get ( key ) ) ) { System . out . println ( a ) ; } else { System . out . println ( b ) ; } } } static void nearestPowerOfTwo ( String S ) { int N = S . length ( ) ; HashMap < Character , Integer > freq = new HashMap < > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { freq . put ( S . charAt ( i ) , freq . getOrDefault ( S . charAt ( i ) , 0 ) + 1 ) ; } nearestPowerOfTwoUtil ( freq ) ; } public static void main ( String [ ] args ) { String N = "16333331163" ; nearestPowerOfTwo ( N ) ; } }

Accumulator variables: i
Iterator variables: i, key
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int gcd ( int a , int b ) { if ( b == 0 ) return a ; return gcd ( b , a % b ) ; } static int lcm ( int a , int b ) { return ( a / gcd ( a , b ) ) * b ; } static void findSmallestString ( String s , String t ) { int n = s . length ( ) , m = t . length ( ) ; int l = lcm ( n , m ) ; String s1 = " " , t1 = " " ; for ( int i = 0 ; i < l / n ; i ++ ) { s1 += s ; } for ( int i = 0 ; i < l / m ; i ++ ) { t1 += t ; } if ( s1 . equals ( t1 ) ) { System . out . println ( s1 ) ; } else { System . out . println ( - 1 ) ; } } public static void main ( String [ ] args ) { String S = " baba " , T = " ba " ; findSmallestString ( S , T ) ; } }

Accumulator variables: i, s1, t1
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . lang . * ; import java . util . * ; class GFG { static int minRemovals ( String str , int N ) { int ans = 0 ; boolean X = false ; for ( int i = 0 ; i < N ; i ++ ) { if ( str . charAt ( i ) == '0' ) { ans ++ ; while ( i < N && str . charAt ( i ) == '0' ) { i ++ ; } } else { X = true ; } } if ( ! X ) return 1 ; if ( str . charAt ( 0 ) == '0' && str . charAt ( N - 1 ) == '0' ) { ans -- ; } return ans ; } public static void main ( String [ ] args ) { String S = "11010001" ; int N = S . length ( ) ; System . out . println ( minRemovals ( S , N ) ) ; } }

Accumulator variables: ans, i
Iterator variables: i
Boolean variables: X
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int minimumDeletions ( String s ) { int right_0 = ( int ) ( s . chars ( ) . filter ( ch -> ch == '0' ) . count ( ) ) ; int left_1 = 0 ; int n = s . length ( ) ; int res = Integer . MAX_VALUE ; for ( int i = 0 ; i < n ; i ++ ) { if ( s . charAt ( i ) == '0' ) { right_0 -= 1 ; } else { left_1 += 1 ; } res = Math . min ( res , right_0 + left_1 ) ; } return res ; } public static void main ( String [ ] args ) { String s = "001101" ; int count = minimumDeletions ( s ) ; System . out . print ( count ) ; } }

Accumulator variables: i, left_1, right_0
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int canMakeSame ( String s1 , String s2 ) { int ans = 0 ; if ( s1 . length ( ) != s2 . length ( ) ) { return - 1 ; } int N = s1 . length ( ) ; for ( int i = 0 ; i < N ; i ++ ) { if ( s1 . charAt ( i ) != s2 . charAt ( i ) ) { while ( i < s1 . length ( ) && s1 . charAt ( i ) != s2 . charAt ( i ) ) { i ++ ; } ans ++ ; } } return ans ; } public static void main ( String [ ] args ) { String S1 = "100001" ; String S2 = "110111" ; System . out . println ( canMakeSame ( S1 , S2 ) ) ; } }

Accumulator variables: ans, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int convert ( String str ) { str = str . substring ( 0 , 2 ) + str . substring ( 3 ) ; int h1 = ( int ) str . charAt ( 1 ) - '0' ; int h2 = ( int ) str . charAt ( 0 ) - '0' ; int hh = ( h2 * 10 + h1 % 10 ) ; int time = 0 ; if ( str . charAt ( 5 ) == ' A ' ) { if ( hh == 12 ) time += Integer . parseInt ( str . substring ( 2 , 4 ) ) ; else { time += Integer . parseInt ( str . substring ( 0 , 2 ) ) ; } } else { if ( hh == 12 ) { time += Integer . parseInt ( str . substring ( 0 , 4 ) ) ; } else { time += Integer . parseInt ( str . substring ( 0 , 4 ) ) ; time += 1200 ; } } return time ; } static int countOverlap ( String arr [ ] [ ] , int n , String p ) { int ans = 0 ; int M = convert ( p ) ; for ( int i = 0 ; i < n ; i ++ ) { int L = convert ( arr [ i ] [ 0 ] ) ; int R = convert ( arr [ i ] [ 1 ] ) ; if ( ( L <= M && M <= R ) || ( M >= R && M <= L ) ) ans ++ ; } return ans ; } public static void main ( String [ ] args ) { String [ ] [ ] arr = new String [ ] [ ] { { "12:00 : AM " , "11:55 : PM " } , { "12:01 : AM " , "11:50 : AM " } , { "12:30 : AM " , "12:00 : PM " } , { "11:57 : AM " , "11:59 : PM " } } ; String P = "12:01 : PM " ; int N = arr . length ; System . out . println ( countOverlap ( arr , N , P ) ) ; } }

Index/key variables: i
Accumulator variables: ans, i, time
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . lang . * ; import java . util . * ; class GFG { static int count ( String S , int X , int Y ) { int N = S . length ( ) ; int temp_x = 0 , temp_y = 0 ; int count = 0 ; HashSet < String > s = new HashSet < > ( ) ; s . add ( ( X + " # " + Y ) ) ; for ( int i = 0 ; i < N ; i ++ ) { temp_x = X ; temp_y = Y ; if ( S . charAt ( i ) == ' U ' ) { X ++ ; } else if ( S . charAt ( i ) == ' D ' ) { X -- ; } else if ( S . charAt ( i ) == ' R ' ) { Y ++ ; } else { Y -- ; } if ( s . contains ( ( temp_x + X ) + " # " + ( temp_y + Y ) ) ) { count ++ ; } else { s . add ( ( temp_x + X ) + " # " + ( temp_y + Y ) ) ; } } return count ; } public static void main ( String [ ] args ) { String S = " RDDUDL " ; int X = 0 , Y = 0 ; System . out . print ( count ( S , X , Y ) ) ; } }

Accumulator variables: X, Y, count, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . HashSet ; class GFG { static void countTotalFrequencies ( String S1 , String S2 ) { HashSet < Character > bset = new HashSet < Character > ( ) ; char [ ] S1arr = S1 . toCharArray ( ) ; char [ ] S2arr = S2 . toCharArray ( ) ; for ( char x : S1arr ) bset . add ( x ) ; int count = 0 ; for ( char x : S2arr ) { if ( bset . contains ( x ) ) count += 1 ; } System . out . print ( count ) ; } public static void main ( String [ ] args ) { String S1 = " geEksFOR " ; String S2 = " GeEksforgeEKS " ; countTotalFrequencies ( S1 , S2 ) ; } }

Accumulator variables: count
Iterator variables: x
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int nonDecreasing ( char [ ] s ) { int size = s . length ; char c = ' a ' ; for ( int i = 0 ; i < size ; i ++ ) { if ( s [ i ] == ' ? ' ) { continue ; } else if ( ( s [ i ] != ' ? ' ) && ( s [ i ] < c ) ) { return 0 ; } else { c = s [ i ] ; } } return 1 ; } public static void main ( String [ ] args ) { String S = " abb ? xy ? " ; if ( nonDecreasing ( S . toCharArray ( ) ) == 1 ) System . out . print ( " Yes " + "NEW_LINE"); else System . out . print ( " No " + "NEW_LINE"); } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { public static void min_length ( String str ) { int n = str . length ( ) ; int total_zeros = 0 ; int total_ones = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( str . charAt ( i ) == '0' ) { total_zeros ++ ; } else { total_ones ++ ; } } int ans = Math . min ( total_zeros , total_ones ) ; int cur_zeros = 0 , cur_ones = 0 ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { char x = str . charAt ( i ) ; if ( x == '0' ) { cur_zeros ++ ; } else { cur_ones ++ ; } ans = Math . min ( ans , cur_ones + ( total_zeros - cur_zeros ) ) ; } System . out . println ( ans ) ; } public static void main ( String [ ] args ) { String str = "10011" ; min_length ( str ) ; } }

Accumulator variables: cur_ones, cur_zeros, i, total_ones, total_zeros
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static String make_palindrome ( String S1 , String S2 , String S3 ) { int maskA = 0 , maskC = 0 ; for ( char i : S1 . toCharArray ( ) ) maskA |= ( 1 << ( i - ' a ' ) ) ; for ( char i : S3 . toCharArray ( ) ) maskC |= ( 1 << ( i - ' a ' ) ) ; if ( ( maskA & maskC ) > 0 ) return " YES " ; return " NO " ; } public static void main ( String [ ] args ) { String S1 = " adcb " , S2 = " bcdb " , S3 = " abe " ; System . out . print ( make_palindrome ( S1 , S2 , S3 ) ) ; } }

Accumulator variables: maskA, maskC
Iterator variables: i
Class/struct names: GFG
Java program:
public class Main { static int SIZE = 26 ; static boolean longHelper ( int [ ] freq1 , int [ ] freq2 ) { for ( int i = 0 ; i < SIZE ; ++ i ) { if ( freq1 [ i ] != freq2 [ i ] ) { return false ; } } return true ; } static void longCommomPrefixAnagram ( String s1 , String s2 , int n1 , int n2 ) { int [ ] freq1 = new int [ 26 ] ; int [ ] freq2 = new int [ 26 ] ; int ans = 0 ; int mini_len = Math . min ( n1 , n2 ) ; for ( int i = 0 ; i < mini_len ; ++ i ) { freq1 [ s1 . charAt ( i ) - ' a ' ] ++ ; freq2 [ s2 . charAt ( i ) - ' a ' ] ++ ; if ( longHelper ( freq1 , freq2 ) ) { ans = i + 1 ; } } System . out . print ( ans ) ; } public static void main ( String [ ] args ) { String str1 = " abaabcdezzwer " ; String str2 = " caaabbttyh " ; int N = str1 . length ( ) ; int M = str2 . length ( ) ; longCommomPrefixAnagram ( str1 , str2 , N , M ) ; } }

Index/key variables: i
Iterator variables: i
Class/struct names: Main