dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
class GFG { public static void balancedString ( String str ) { int count = 0 , i ; int n = str . length ( ) ; for ( i = 0 ; i < n ; i ++ ) { if ( str . charAt ( i ) == ' ( ' ) { System . out . print ( str . charAt ( i ) ) ; count ++ ; } else if ( str . charAt ( i ) == ' ) ' && count != 0 ) { System . out . print ( str . charAt ( i ) ) ; count -- ; } else if ( str . charAt ( i ) != ' ) ' ) System . out . print ( str . charAt ( i ) ) ; } if ( count != 0 ) for ( i = 0 ; i < count ; i ++ ) System . out . print ( " ) " ) ; } public static void main ( String args [ ] ) { String str = " gau ) ra ) v ( ku ( mar ( rajput ) ) " ; balancedString ( str ) ; } }

Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static final int MAX = Integer . MAX_VALUE ; static int minOperation ( String s , int i , int j , int count ) { if ( ( i >= s . length ( ) && j < 0 ) || ( i == j ) ) return MAX ; if ( s . charAt ( i ) == s . charAt ( j ) ) return count ; if ( i >= s . length ( ) ) return minOperation ( s , i , j - 1 , count + 1 ) ; else if ( j < 0 ) return minOperation ( s , i + 1 , j , count + 1 ) ; else return Math . min ( minOperation ( s , i , j - 1 , count + 1 ) , minOperation ( s , i + 1 , j , count + 1 ) ) ; } public static void main ( String [ ] args ) { String s = " bacdefghipalop " ; int ans = minOperation ( s , 0 , s . length ( ) - 1 , 0 ) ; if ( ans == MAX ) System . out . println ( - 1 ) ; else System . out . println ( ans ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; import java . lang . * ; import java . io . * ; class GFG { static int countStrings ( String s ) { int sum = 1 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( i % 2 == 0 && s . charAt ( i ) == ' $ ' ) sum *= 21 ; else if ( s . charAt ( i ) == ' $ ' ) sum *= 5 ; } return sum ; } public static void main ( String args [ ] ) { String str = " s $ $ e $ " ; System . out . println ( countStrings ( str ) ) ; } }

Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . Arrays ; class GFG { static char [ ] removeDuplicatesFromString ( String string ) { int counter = 0 ; char [ ] str = string . toCharArray ( ) ; int i = 0 ; int size = str . length ; int x ; int length = 0 ; while ( i < size ) { x = str [ i ] - 97 ; if ( ( counter & ( 1 << x ) ) == 0 ) { str [ length ] = ( char ) ( ' a ' + x ) ; counter = counter | ( 1 << x ) ; length ++ ; } i ++ ; } return Arrays . copyOfRange ( str , 0 , length ) ; } public static void main ( String [ ] args ) { String str = " geeksforgeeks " ; System . out . println ( removeDuplicatesFromString ( str ) ) ; } }

Index/key variables: i, length
Accumulator variables: i, length
Class/struct names: GFG
Java program:
import java . util . Arrays ; class GFG { static char [ ] removeDuplicatesFromString ( String string ) { int [ ] table = new int [ 256 ] ; char [ ] chars = string . toCharArray ( ) ; int endIndex = 0 ; for ( int i = 0 ; i < chars . length ; i ++ ) { if ( table [ chars [ i ] ] == 0 ) { table [ chars [ i ] ] = - 1 ; chars [ endIndex ++ ] = chars [ i ] ; } } return Arrays . copyOfRange ( chars , 0 , endIndex ) ; } public static void main ( String [ ] args ) { String str = " geeksforgeeks " ; System . out . println ( removeDuplicatesFromString ( str ) ) ; } }

Index/key variables: i
Accumulator variables: endIndex, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int firstPos ( String str , int start , int end ) { int firstChar = - 1 ; for ( int i = start ; i <= end ; i ++ ) { if ( str . charAt ( i ) >= ' a ' && str . charAt ( i ) <= ' z ' ) { firstChar = i ; break ; } } return firstChar ; } static int lastPos ( String str , int start , int end ) { int lastChar = - 1 ; for ( int i = start ; i >= end ; i -- ) { if ( str . charAt ( i ) >= ' a ' && str . charAt ( i ) <= ' z ' ) { lastChar = i ; break ; } } return lastChar ; } static boolean isPalindrome ( String str ) { int firstChar = 0 , lastChar = str . length ( ) - 1 ; boolean ch = true ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { firstChar = firstPos ( str , firstChar , lastChar ) ; lastChar = lastPos ( str , lastChar , firstChar ) ; if ( lastChar < 0 firstChar < 0 ) break ; if ( str . charAt ( firstChar ) == str . charAt ( lastChar ) ) { firstChar ++ ; lastChar -- ; continue ; } ch = false ; break ; } return ch ; } public static void main ( String [ ] args ) { String str = " m ▁ a ▁ 343 ▁ la ▁ y ▁ a ▁ l ▁ am " ; if ( isPalindrome ( str ) ) System . out . print ( " YES " ) ; else System . out . println ( " NO " ) ; } }

Accumulator variables: firstChar, i, lastChar
Iterator variables: i
Boolean variables: ch
Class/struct names: GFG
Java program:
public class gfg { int find ( String s ) { int max = 0 , i , j = 0 , countk = 0 , countr = 0 ; int table [ ] [ ] = new int [ s . length ( ) ] [ 2 ] ; for ( i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == ' R ' ) countr ++ ; else table [ j ++ ] [ 0 ] = countr ; } j -- ; for ( i = s . length ( ) - 1 ; i >= 0 ; i -- ) { if ( s . charAt ( i ) == ' K ' ) { countk ++ ; table [ j -- ] [ 1 ] = countk ; } if ( Math . min ( table [ j + 1 ] [ 0 ] , table [ j + 1 ] [ 1 ] ) > max ) max = Math . min ( table [ j + 1 ] [ 0 ] , table [ j + 1 ] [ 1 ] ) ; } return max ; } public static void main ( String srgs [ ] ) { String s = " RKRRRKKRRKKKKRR " ; gfg ob = new gfg ( ) ; int n = ob . find ( s ) ; System . out . println ( n ) ; } }

Accumulator variables: countk, countr, i, j
Iterator variables: i
Class/struct names: gfg
Java program:
class GFG { final int MAX_CHAR = 26 ; static void frequency ( int fre [ ] [ ] , String s [ ] , int n ) { for ( int i = 0 ; i < n ; i ++ ) { String str = s [ i ] ; for ( int j = 0 ; j < str . length ( ) ; j ++ ) fre [ i ] [ str . charAt ( j ) - ' a ' ] ++ ; } } static void LongestSequence ( int fre [ ] [ ] , int n ) { for ( int i = 24 ; i >= 0 ; i -- ) { int mi = fre [ 0 ] [ i ] ; for ( int j = 1 ; j < n ; j ++ ) mi = Math . min ( fre [ j ] [ i ] , mi ) ; while ( mi -- != 0 ) System . out . print ( ( char ) ( ' a ' + i ) ) ; } } public static void main ( String args [ ] ) { String s [ ] = { " loo " , " lol " , " olive " } ; int n = s . length ; int fre [ ] [ ] = new int [ n ] [ 26 ] ; frequency ( fre , s , n ) ; LongestSequence ( fre , n ) ; } }

Index/key variables: i, j, n
Accumulator variables: i, j, mi
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GfG { static boolean arePermutation ( String str1 , String str2 ) { int n1 = str1 . length ( ) ; int n2 = str2 . length ( ) ; if ( n1 != n2 ) return false ; char ch1 [ ] = str1 . toCharArray ( ) ; char ch2 [ ] = str2 . toCharArray ( ) ; Arrays . sort ( ch1 ) ; Arrays . sort ( ch2 ) ; for ( int i = 0 ; i < n1 ; i ++ ) if ( ch1 [ i ] != ch2 [ i ] ) return false ; return true ; } public static void main ( String [ ] args ) { String str1 = " test " ; String str2 = " ttew " ; if ( arePermutation ( str1 , str2 ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GfG
Java program:
static boolean arePermutation ( char str1 [ ] , char str2 [ ] ) { int count [ ] = new int [ NO_OF_CHARS ] ; int i ; for ( i = 0 ; str1 [ i ] && str2 [ i ] ; i ++ ) { count [ str1 [ i ] ] ++ ; count [ str2 [ i ] ] -- ; } if ( str1 [ i ] str2 [ i ] ) return false ; for ( i = 0 ; i < NO_OF_CHARS ; i ++ ) if ( count [ i ] != 0 ) return false ; return true ; }

Index/key variables: NO_OF_CHARS, i
Accumulator variables: i
Iterator variables: i
Java program:
import java . util . ArrayList ; public class string_sort { public static int powerOfJump ( String s ) { int count = 1 ; int max_so_far = Integer . MIN_VALUE ; char ch = s . charAt ( s . length ( ) - 1 ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == ch ) { if ( count > max_so_far ) { max_so_far = count ; } count = 1 ; } else count ++ ; } return max_so_far ; } public static void main ( String [ ] args ) { String st = "1010101" ; System . out . println ( powerOfJump ( st ) ) ; } }

Accumulator variables: count, i
Iterator variables: i
Class/struct names: string_sort
Java program:
import java . util . HashMap ; class GFG { static int findLongestSub ( String bin ) { int n = bin . length ( ) , i ; int sum = 0 ; HashMap < Integer , Integer > prevSum = new HashMap < > ( ) ; int maxlen = 0 ; int currlen ; for ( i = 0 ; i < n ; i ++ ) { if ( bin . charAt ( i ) == '1' ) sum ++ ; else sum -- ; if ( sum > 0 ) { maxlen = i + 1 ; } else if ( sum <= 0 ) { if ( prevSum . containsKey ( sum - 1 ) ) { currlen = i - ( prevSum . get ( sum - 1 ) == null ? 1 : prevSum . get ( sum - 1 ) ) ; maxlen = Math . max ( maxlen , currlen ) ; } } if ( ! prevSum . containsKey ( sum ) ) prevSum . put ( sum , i ) ; } return maxlen ; } public static void main ( String [ ] args ) { String bin = "1010" ; System . out . println ( findLongestSub ( bin ) ) ; } }

Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { public static int averageValue ( String s ) { int sum_char = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { sum_char += ( int ) s . charAt ( i ) ; } return sum_char / s . length ( ) ; } public static void main ( String [ ] args ) { String s = " GeeksforGeeks " ; System . out . println ( averageValue ( s ) ) ; } }

Accumulator variables: i, sum_char
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; import java . util . Arrays ; class GFG { static boolean check ( String s , int l ) { int freq [ ] = new int [ 26 ] ; Arrays . fill ( freq , 0 ) ; for ( int i = 0 ; i < l ; i ++ ) { freq [ s . charAt ( i ) - ' a ' ] ++ ; } for ( int i = 0 ; i < 26 ; i ++ ) { if ( freq [ i ] >= 2 ) return true ; } return false ; } public static void main ( String args [ ] ) { String s = " geeksforgeeks " ; int l = s . length ( ) ; if ( check ( s , l ) ) System . out . print ( " YES " ) ; else System . out . print ( " NO " ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; import java . lang . * ; class GFG { static void predictWinner ( String score , int n ) { int count [ ] = new int [ 2 ] , i ; for ( i = 0 ; i < score . length ( ) ; i ++ ) { count [ score . charAt ( i ) - '0' ] ++ ; if ( count [ 0 ] == n && count [ 1 ] < n - 1 ) { System . out . print ( " GEEKS ▁ lost " ) ; return ; } if ( count [ 1 ] == n && count [ 0 ] < n - 1 ) { System . out . print ( " GEEKS ▁ won " ) ; return ; } if ( count [ 0 ] == n - 1 && count [ 1 ] == n - 1 ) { count [ 0 ] = 0 ; count [ 1 ] = 0 ; break ; } } for ( i ++ ; i < score . length ( ) ; i ++ ) { count [ score . charAt ( i ) - '0' ] ++ ; if ( Math . abs ( count [ 0 ] - count [ 1 ] ) == 2 ) { if ( count [ 0 ] > count [ 1 ] ) System . out . print ( " GEEKS ▁ lost " ) ; else System . out . print ( " GEEKS ▁ won " ) ; return ; } } } public static void main ( String [ ] args ) { String score = "1001010101111011101111" ; int n = 15 ; predictWinner ( score , n ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static boolean isPalindrome ( String str , int l , int r ) { while ( l < r ) { if ( str . charAt ( l ) != str . charAt ( r ) ) return false ; l ++ ; r -- ; } return true ; } static int CyclicShifts ( String str ) { int n = str . length ( ) ; int left = 0 ; int right = n - 1 ; str = str + str ; int cnt = 0 ; while ( right < 2 * n - 1 ) { if ( isPalindrome ( str , left , right ) ) break ; cnt ++ ; left ++ ; right ++ ; } return cnt ; } public static void main ( String [ ] args ) { String str = " bccbbaab " ; System . out . println ( CyclicShifts ( str ) ) ; } }

Accumulator variables: cnt, l, left, r, right
Class/struct names: GFG
Java program:
class GFG { static String printString ( int n , String str ) { String str2 = " " ; int extraChar = n % 26 ; if ( extraChar >= 1 ) { for ( int i = 26 - ( extraChar + 1 ) ; i <= 25 ; i ++ ) { str2 += str . charAt ( i ) ; } } int countOfStr = n / 26 ; for ( int i = 1 ; i <= countOfStr ; i ++ ) { for ( int j = 0 ; j < 26 ; j ++ ) { str2 += str . charAt ( j ) ; } } return str2 ; } public static void main ( String [ ] args ) { int n = 30 ; String str = " zyxwvutsrqponmlkjihgfedcba " ; System . out . println ( printString ( n , str ) ) ; } }

Accumulator variables: i, j, str2
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . Arrays ; class GFG { static String commonPrefixUtil ( String str1 , String str2 ) { String result = " " ; int n1 = str1 . length ( ) , n2 = str2 . length ( ) ; for ( int i = 0 , j = 0 ; i <= n1 - 1 && j <= n2 - 1 ; i ++ , j ++ ) { if ( str1 . charAt ( i ) != str2 . charAt ( j ) ) { break ; } result += str1 . charAt ( i ) ; } return ( result ) ; } static void commonPrefix ( String arr [ ] , int n ) { Arrays . sort ( arr ) ; System . out . println ( commonPrefixUtil ( arr [ 0 ] , arr [ n - 1 ] ) ) ; } public static void main ( String [ ] args ) { String arr [ ] = { " geeksforgeeks " , " geeks " , " geek " , " geezer " } ; int n = arr . length ; commonPrefix ( arr , n ) ; } }

Accumulator variables: i, j, result
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { public static String multiply ( String num1 , String num2 ) { int n1 = num1 . length ( ) ; int n2 = num2 . length ( ) ; if ( n1 == 0 n2 == 0 ) return "0" ; int [ ] result = new int [ n1 + n2 ] ; int i_n1 = 0 ; int i_n2 = 0 ; for ( int i = n1 - 1 ; i >= 0 ; i -- ) { int carry = 0 ; int n_1 = num1 . charAt ( i ) - '0' ; i_n2 = 0 ; for ( int j = n2 - 1 ; j >= 0 ; j -- ) { int n_2 = num2 . charAt ( j ) - '0' ; int sum = n_1 * n_2 + result [ i_n1 + i_n2 ] + carry ; carry = sum / 10 ; result [ i_n1 + i_n2 ] = sum % 10 ; i_n2 ++ ; } if ( carry > 0 ) result [ i_n1 + i_n2 ] += carry ; i_n1 ++ ; } int i = result . length - 1 ; while ( i >= 0 && result [ i ] == 0 ) i -- ; if ( i == - 1 ) return "0" ; String s = " " ; while ( i >= 0 ) s += Integer . toString ( result [ i -- ] ) ; return s ; } public static void main ( String [ ] args ) { String str1 = "454545454545454545" ; System . out . println ( multiply ( str1 , str1 ) ) ; } }

Index/key variables: i
Accumulator variables: i, i_n1, i_n2, j, s
Iterator variables: i, j
Class/struct names: GFG
Java program:
class GFG { public static void countDigits ( String st , int n ) { if ( n > 0 ) { int cnt = 1 , i ; String st2 = " " ; for ( i = 1 ; i < st . length ( ) ; i ++ ) { if ( st . charAt ( i ) == st . charAt ( i - 1 ) ) cnt ++ ; else { st2 += ( ( char ) 0 + ( char ) cnt ) ; st2 += st . charAt ( i - 1 ) ; cnt = 1 ; } } st2 += ( ( char ) 0 + ( char ) cnt ) ; st2 += st . charAt ( i - 1 ) ; countDigits ( st2 , -- n ) ; } else System . out . print ( st ) ; } public static void main ( String [ ] args ) { String num = "123" ; int n = 3 ; countDigits ( num , n ) ; } }

Accumulator variables: cnt, i, st2
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; import java . io . * ; public class SpecialSubsequences { public static void generateSubsequences ( String input , String output , int index , ArrayList < String > ans ) { if ( index == input . length ( ) ) { if ( output . length ( ) != 0 ) { ans . add ( output ) ; } return ; } generateSubsequences ( input , output , index + 1 , ans ) ; output += String . valueOf ( input . charAt ( index ) ) ; generateSubsequences ( input , output , index + 1 , ans ) ; output = output . substring ( 0 , output . length ( ) - 1 ) ; output += String . valueOf ( Character . toUpperCase ( input . charAt ( index ) ) ) ; generateSubsequences ( input , output , index + 1 , ans ) ; } public static void printSubsequences ( String s ) { String output = " " ; ArrayList < String > ans = new ArrayList < > ( ) ; generateSubsequences ( s , output , 0 , ans ) ; Collections . sort ( ans ) ; for ( String str : ans ) { System . out . print ( str + " ▁ " ) ; } System . out . println ( ) ; } public static void main ( String [ ] args ) { String s = " ab " ; printSubsequences ( s ) ; } }

Accumulator variables: output
Iterator variables: str
Class/struct names: SpecialSubsequences
Java program:
import java . util . * ; class GFG { static boolean match_words ( String dictionary [ ] , String sentence [ ] , int n , int m ) { Map < String , Integer > mp = new HashMap < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( mp . containsKey ( dictionary [ i ] ) ) { mp . put ( dictionary [ i ] , mp . get ( dictionary [ i ] ) + 1 ) ; } else { mp . put ( dictionary [ i ] , 1 ) ; } } for ( int i = 0 ; i < m ; i ++ ) { if ( mp . containsKey ( sentence [ i ] ) ) mp . put ( sentence [ i ] , mp . get ( sentence [ i ] ) - 1 ) ; else return false ; } return true ; } public static void main ( String [ ] args ) { String dictionary [ ] = { " find " , " a " , " geeks " , " all " , " for " , " on " , " geeks " , " answers " , " inter " } ; int n = dictionary . length ; String sentence [ ] = { " find " , " all " , " answers " , " on " , " geeks " , " for " , " geeks " } ; int m = sentence . length ; if ( match_words ( dictionary , sentence , n , m ) ) System . out . println ( " YES " ) ; else System . out . println ( " NO " ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; import java . lang . * ; public class GFG { static void printNum ( String s ) { int i = 0 , j = 0 , val = 0 ; LinkedHashMap < Integer , Integer > hm = new LinkedHashMap < > ( ) ; val = ( s . charAt ( 0 ) - '0' ) * 100 + ( s . charAt ( 1 ) - '0' ) * 10 + ( s . charAt ( 2 ) - '0' ) ; hm . put ( val , 1 ) ; for ( i = 3 ; i < s . length ( ) ; i ++ ) { val = ( val % 100 ) * 10 + s . charAt ( i ) - '0' ; if ( hm . containsKey ( val ) ) { hm . put ( val , hm . get ( val ) + 1 ) ; } else { hm . put ( val , 1 ) ; } } for ( Map . Entry < Integer , Integer > en : hm . entrySet ( ) ) { int key = en . getKey ( ) ; int value = en . getValue ( ) ; if ( value > 1 ) System . out . println ( key + " ▁ - ▁ " + value + " ▁ times " ) ; } } public static void main ( String args [ ] ) { String input = "123412345123456" ; printNum ( input ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int countSubstrig ( String str1 , String str2 ) { int n1 = str1 . length ( ) ; int n2 = str2 . length ( ) ; if ( n1 == 0 n1 < n2 ) return 0 ; if ( str1 . substring ( 0 , n2 ) . equals ( str2 ) ) return countSubstrig ( str1 . substring ( n2 - 1 ) , str2 ) + 1 ; return countSubstrig ( str1 . substring ( n2 - 1 ) , str2 ) ; } public static void main ( String args [ ] ) { String str1 = " geeksforgeeks " , str2 = " geeks " ; System . out . println ( countSubstrig ( str1 , str2 ) ) ; str1 = " hikakashi " ; str2 = " hi " ; System . out . println ( countSubstrig ( str1 , str2 ) ) ; } }

Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { static boolean hasAllcodes ( String s , int k ) { Set < String > us = new HashSet < String > ( ) ; for ( int i = 0 ; i + k <= s . length ( ) ; i ++ ) { us . add ( s . substring ( i , i + k ) ) ; } return ( us . size ( ) == ( 1 << k ) ) ; } public static void main ( String [ ] args ) { String s = "00110110" ; int k = 2 ; if ( hasAllcodes ( s , k ) ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static String addBinaryUtil ( String a , String b ) { String result = " " ; int s = 0 ; int i = a . length ( ) - 1 , j = b . length ( ) - 1 ; while ( i >= 0 j >= 0 s == 1 ) { s += ( ( i >= 0 ) ? a . charAt ( i ) - '0' : 0 ) ; s += ( ( j >= 0 ) ? b . charAt ( j ) - '0' : 0 ) ; result = s % 2 + result ; s /= 2 ; i -- ; j -- ; } return result ; } static String addBinary ( String arr [ ] , int n ) { String result = " " ; for ( int i = 0 ; i < n ; i ++ ) { result = addBinaryUtil ( result , arr [ i ] ) ; } return result ; } public static void main ( String [ ] args ) { String arr [ ] = { "1" , "10" , "11" } ; int n = arr . length ; System . out . println ( addBinary ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: i, j, s
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static void reverse ( char str [ ] , int start , int end ) { char temp ; while ( start <= end ) { temp = str [ start ] ; str [ start ] = str [ end ] ; str [ end ] = temp ; start ++ ; end -- ; } } static void reverseletter ( char str [ ] , int start , int end ) { int wstart , wend ; for ( wstart = wend = start ; wend < end ; wend ++ ) { if ( str [ wend ] == ' ▁ ' ) { continue ; } while ( wend <= end && str [ wend ] != ' ▁ ' ) { wend ++ ; } wend -- ; reverse ( str , wstart , wend ) ; } } public static void main ( String [ ] args ) { char str [ ] = " Ashish ▁ Yadav ▁ Abhishek ▁ Rajput ▁ Sunil ▁ Pundir " . toCharArray ( ) ; reverseletter ( str , 0 , str . length - 1 ) ; System . out . printf ( " % s " , String . valueOf ( str ) ) ; } }

Index/key variables: end, start, wend
Accumulator variables: end, start, wend
Iterator variables: wstart
Class/struct names: GFG
Java program:
class GFG { static void minimumFlip ( String s , int x , int y ) { s = s + s ; boolean isOpposite = false ; if ( x > y ) { swap ( x , y ) ; isOpposite = true ; } int valClockwise = 0 ; char cur = s . charAt ( x ) ; for ( int i = x ; i <= y ; i ++ ) { if ( s . charAt ( i ) != cur ) { cur = s . charAt ( i ) ; valClockwise ++ ; } } int valAnticlockwise = 0 ; cur = s . charAt ( y ) ; x += s . length ( ) ; for ( int i = y ; i < x ; i ++ ) { if ( s . charAt ( i ) != cur ) { cur = s . charAt ( i ) ; valAnticlockwise ++ ; } } if ( valClockwise <= valAnticlockwise ) { if ( ! isOpposite ) { System . out . println ( " Clockwise ▁ " + valClockwise ) ; } else { System . out . println ( " Anti - clockwise ▁ " + valAnticlockwise ) ; } } else if ( ! isOpposite ) { System . out . println ( " Anti - clockwise ▁ " + valAnticlockwise ) ; } else { System . out . println ( " Clockwise ▁ " + valClockwise ) ; } } static void swap ( int a , int b ) { int c = a ; a = b ; b = c ; } public static void main ( String [ ] args ) { int x = 0 , y = 8 ; String s = "000110" ; minimumFlip ( s , x , y ) ; } }

Accumulator variables: i, valAnticlockwise, valClockwise, x
Iterator variables: i
Boolean variables: isOpposite
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int prefix ( String k , int n ) { int a = 0 , b = 0 , count = 0 ; int i = 0 ; int len = k . length ( ) ; for ( i = 0 ; i < len ; i ++ ) { if ( k . charAt ( i ) == ' a ' ) a ++ ; if ( k . charAt ( i ) == ' b ' ) b ++ ; if ( a > b ) { count ++ ; } } if ( count == 0 n == 1 ) { System . out . println ( count ) ; return 0 ; } if ( count == len a - b == 0 ) { System . out . println ( count * n ) ; return 0 ; } int n2 = n - 1 , count2 = 0 ; while ( n2 != 0 ) { for ( i = 0 ; i < len ; i ++ ) { if ( k . charAt ( i ) == ' a ' ) a ++ ; if ( k . charAt ( i ) == ' b ' ) b ++ ; if ( a > b ) { count2 ++ ; } } count += count2 ; n2 -- ; if ( count2 == 0 ) break ; if ( count2 == len ) { count += ( n2 * count2 ) ; break ; } count2 = 0 ; } return count ; } public static void main ( String [ ] args ) { String S = " aba " ; int N = 2 ; System . out . println ( prefix ( S , N ) ) ; S = " baa " ; N = 3 ; System . out . println ( prefix ( S , N ) ) ; } }

Accumulator variables: a, b, count, count2, i, n2
Iterator variables: i
Class/struct names: GFG