dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
class Test { static void printRotatedString ( String str ) { int len = str . length ( ) ; StringBuffer sb ; for ( int i = 0 ; i < len ; i ++ ) { sb = new StringBuffer ( ) ; int j = i ; int k = 0 ; for ( int k2 = j ; k2 < str . length ( ) ; k2 ++ ) { sb . insert ( k , str . charAt ( j ) ) ; k ++ ; j ++ ; } j = 0 ; while ( j < i ) { sb . insert ( k , str . charAt ( j ) ) ; j ++ ; k ++ ; } System . out . println ( sb ) ; } } public static void main ( String [ ] args ) { String str = new String ( " geeks " ) ; printRotatedString ( str ) ; } }

Accumulator variables: i, j, k, k2
Iterator variables: i, k2
Class/struct names: Test
Java program:
public class GFG { static Boolean isPalindrome ( String str ) { int n = str . length ( ) ; for ( int i = 0 ; i < n / 2 ; i ++ ) if ( str . charAt ( i ) != str . charAt ( n - i - 1 ) ) return false ; return true ; } static int maxLengthNonPalinSubstring ( String str ) { int n = str . length ( ) ; char ch = str . charAt ( 0 ) ; int i = 1 ; for ( i = 1 ; i < n ; i ++ ) if ( str . charAt ( i ) != ch ) break ; if ( i == n ) return 0 ; if ( isPalindrome ( str ) ) return n - 1 ; return n ; } public static void main ( String args [ ] ) { String str = " abba " ; System . out . println ( " Maximum ▁ Length ▁ = ▁ " + maxLengthNonPalinSubstring ( str ) ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static void moveSpaceInFront ( char str [ ] ) { int i = str . length - 1 ; for ( int j = i ; j >= 0 ; j -- ) if ( str [ j ] != ' ▁ ' ) { char c = str [ i ] ; str [ i ] = str [ j ] ; str [ j ] = c ; i -- ; } } public static void main ( String [ ] args ) { char str [ ] = " Hey ▁ there , ▁ it ' s ▁ GeeksforGeeks " . toCharArray ( ) ; moveSpaceInFront ( str ) ; System . out . println ( String . valueOf ( str ) ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: j
Class/struct names: GFG
Java program:
class GFG { static void moveSpaceInFront ( char str [ ] ) { int i = str . length - 1 ; for ( int j = i ; j >= 0 ; j -- ) if ( str [ j ] != ' ▁ ' ) str [ i -- ] = str [ j ] ; while ( i >= 0 ) str [ i -- ] = ' ▁ ' ; } public static void main ( String [ ] args ) { char str [ ] = " Hey ▁ there , ▁ it ' s ▁ GeeksforGeeks " . toCharArray ( ) ; moveSpaceInFront ( str ) ; System . out . println ( String . valueOf ( str ) ) ; } }

Index/key variables: j
Accumulator variables: i, j
Iterator variables: j
Class/struct names: GFG
Java program:
class GFG { static boolean isPalindrome ( char [ ] str ) { int len = str . length ; if ( len == 1 ) return true ; int ptr1 = 0 ; int ptr2 = len - 1 ; while ( ptr2 >= ptr1 ) { if ( str [ ptr1 ] != str [ ptr2 ] ) return false ; ptr1 ++ ; ptr2 -- ; } return true ; } static int noOfAppends ( String s ) { if ( isPalindrome ( s . toCharArray ( ) ) ) return 0 ; s = s . substring ( 1 ) ; return 1 + noOfAppends ( s ) ; } public static void main ( String arr [ ] ) { String s = " abede " ; System . out . printf ( "%dNEW_LINE", noOfAppends(s)); } }

Index/key variables: ptr1, ptr2
Accumulator variables: ptr1, ptr2
Class/struct names: GFG
Java program:
import java . util . * ; import java . lang . * ; class GFG { static int titleToNumber ( String s ) { int result = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { result *= 26 ; result += s . charAt ( i ) - ' A ' + 1 ; } return result ; } public static void main ( String [ ] args ) { System . out . print ( titleToNumber ( " CDA " ) ) ; } }

Accumulator variables: i, result
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static void isKthBitSet ( int n , int k ) { if ( ( ( n >> ( k - 1 ) ) & 1 ) > 0 ) System . out . println ( " SET " ) ; else System . out . println ( " NOT ▁ SET " ) ; } public static void main ( String [ ] args ) { int n = 5 , k = 1 ; isKthBitSet ( n , k ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static String reversingString ( char [ ] str , int start , int end ) { while ( start < end ) { str [ start ] ^= str [ end ] ; str [ end ] ^= str [ start ] ; str [ start ] ^= str [ end ] ; ++ start ; -- end ; } return String . valueOf ( str ) ; } public static void main ( String [ ] args ) { String s = " GeeksforGeeks " ; System . out . println ( reversingString ( s . toCharArray ( ) , 0 , 12 ) ) ; } }

Index/key variables: end, start
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int MAX = 100002 ; static int f ( int i , int m , char s [ ] , int memoize [ ] [ ] ) { if ( i == s . length ) { return 0 ; } if ( memoize [ i ] [ m ] != - 1 ) { return memoize [ i ] [ m ] ; } int x = s [ i ] - '0' ; int ans = ( ( x + m ) % 3 == 0 && x % 2 == 0 ) ? 1 + f ( i + 1 , ( m + x ) % 3 , s , memoize ) : f ( i + 1 , ( m + x ) % 3 , s , memoize ) ; memoize [ i ] [ m ] = ans ; return memoize [ i ] [ m ] ; } static int countDivBy6 ( char s [ ] ) { int n = s . length ; int [ ] [ ] memoize = new int [ n + 1 ] [ 3 ] ; for ( int i = 0 ; i < n + 1 ; i ++ ) { for ( int j = 0 ; j < 3 ; j ++ ) { memoize [ i ] [ j ] = - 1 ; } } int ans = 0 ; for ( int i = 0 ; i < s . length ; i ++ ) { if ( s [ i ] == '0' ) { ans ++ ; } else { ans += f ( i , 0 , s , memoize ) ; } } return ans ; } public static void main ( String [ ] args ) { char s [ ] = "4806" . toCharArray ( ) ; System . out . println ( countDivBy6 ( s ) ) ; } }

Index/key variables: i, j, m
Accumulator variables: ans, i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
class GFG { static char MAX_CHAR = 26 ; static void countFreq ( String str , int freq [ ] , int len ) { for ( int i = 0 ; i < len ; i ++ ) { freq [ str . charAt ( i ) - ' a ' ] ++ ; } } static boolean canMakePalindrome ( int freq [ ] , int len ) { int count_odd = 0 ; for ( int i = 0 ; i < MAX_CHAR ; i ++ ) { if ( freq [ i ] % 2 != 0 ) { count_odd ++ ; } } if ( len % 2 == 0 ) { if ( count_odd > 0 ) { return false ; } else { return true ; } } if ( count_odd != 1 ) { return false ; } return true ; } static String findOddAndRemoveItsFreq ( int freq [ ] ) { String odd_str = " " ; for ( int i = 0 ; i < MAX_CHAR ; i ++ ) { if ( freq [ i ] % 2 != 0 ) { freq [ i ] -- ; odd_str = odd_str + ( char ) ( i + ' a ' ) ; return odd_str ; } } return odd_str ; } static String findPalindromicString ( String str ) { int len = str . length ( ) ; int freq [ ] = new int [ MAX_CHAR ] ; countFreq ( str , freq , len ) ; if ( ! canMakePalindrome ( freq , len ) ) { return " No ▁ Palindromic ▁ String " ; } String odd_str = findOddAndRemoveItsFreq ( freq ) ; String front_str = " " , rear_str = " ▁ " ; for ( int i = 0 ; i < MAX_CHAR ; i ++ ) { String temp = " " ; if ( freq [ i ] != 0 ) { char ch = ( char ) ( i + ' a ' ) ; for ( int j = 1 ; j <= freq [ i ] / 2 ; j ++ ) { temp = temp + ch ; } front_str = front_str + temp ; rear_str = temp + rear_str ; } } return ( front_str + odd_str + rear_str ) ; } public static void main ( String [ ] args ) { String str = " malayalam " ; System . out . println ( findPalindromicString ( str ) ) ; } }

Index/key variables: MAX_CHAR, i
Accumulator variables: count_odd, i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
public class GFG { static boolean checkEquality ( String s ) { return ( s . charAt ( 0 ) == s . charAt ( s . length ( ) - 1 ) ) ; } static int countSubstringWithEqualEnds ( String s ) { int result = 0 ; int n = s . length ( ) ; for ( int i = 0 ; i < n ; i ++ ) for ( int len = 1 ; len <= n - i ; len ++ ) if ( checkEquality ( s . substring ( i , i + len ) ) ) result ++ ; return result ; } public static void main ( String args [ ] ) { String s = " abcab " ; System . out . println ( countSubstringWithEqualEnds ( s ) ) ; } }

Accumulator variables: i, len, result
Iterator variables: i, len
Class/struct names: GFG
Java program:
public class GFG { static int countSubstringWithEqualEnds ( String s ) { int result = 0 ; int n = s . length ( ) ; for ( int i = 0 ; i < n ; i ++ ) for ( int j = i ; j < n ; j ++ ) if ( s . charAt ( i ) == s . charAt ( j ) ) result ++ ; return result ; } public static void main ( String args [ ] ) { String s = " abcab " ; System . out . println ( countSubstringWithEqualEnds ( s ) ) ; } }

Accumulator variables: i, j, result
Iterator variables: i, j
Class/struct names: GFG
Java program:
class GFG { static final int MAX_DIGITS = 6 ; static int getValue ( String str , int i , int m ) { if ( i + m > str . length ( ) ) { return - 1 ; } int value = 0 ; for ( int j = 0 ; j < m ; j ++ ) { int c = str . charAt ( i + j ) - '0' ; if ( c < 0 c > 9 ) { return - 1 ; } value = value * 10 + c ; } return value ; } static int findMissingNumber ( String str ) { for ( int m = 1 ; m <= MAX_DIGITS ; ++ m ) { int n = getValue ( str , 0 , m ) ; if ( n == - 1 ) { break ; } int missingNo = - 1 ; boolean fail = false ; for ( int i = m ; i != str . length ( ) ; i += 1 + Math . log10 ( n ) ) { if ( ( missingNo == - 1 ) && ( getValue ( str , i , ( int ) ( 1 + Math . log10 ( n + 2 ) ) ) == n + 2 ) ) { missingNo = n + 1 ; n += 2 ; else if ( getValue ( str , i , ( int ) ( 1 + Math . log10 ( n + 1 ) ) ) == n + 1 ) { n ++ ; } else { fail = true ; break ; } } if ( ! fail ) { return missingNo ; } } } public static void main ( String [ ] args ) { System . out . println ( findMissingNumber ( "99101102" ) ) ; } }

Accumulator variables: i, j, n
Iterator variables: i, j, m
Boolean variables: fail
Class/struct names: GFG
Java program:
public class GFG { static char maxRepeating ( String str ) { int len = str . length ( ) ; int count = 0 ; char res = str . charAt ( 0 ) ; for ( int i = 0 ; i < len ; i ++ ) { int cur_count = 1 ; for ( int j = i + 1 ; j < len ; j ++ ) { if ( str . charAt ( i ) != str . charAt ( j ) ) break ; cur_count ++ ; } if ( cur_count > count ) { count = cur_count ; res = str . charAt ( i ) ; } } return res ; } public static void main ( String args [ ] ) { String str = " aaaabbaaccde " ; System . out . println ( maxRepeating ( str ) ) ; } }

Accumulator variables: cur_count, i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static String findSum ( String str1 , String str2 ) { if ( str1 . length ( ) > str2 . length ( ) ) { String t = str1 ; str1 = str2 ; str2 = t ; } String str = " " ; int n1 = str1 . length ( ) , n2 = str2 . length ( ) ; str1 = new StringBuilder ( str1 ) . reverse ( ) . toString ( ) ; str2 = new StringBuilder ( str2 ) . reverse ( ) . toString ( ) ; int carry = 0 ; for ( int i = 0 ; i < n1 ; i ++ ) { int sum = ( ( int ) ( str1 . charAt ( i ) - '0' ) + ( int ) ( str2 . charAt ( i ) - '0' ) + carry ) ; str += ( char ) ( sum % 10 + '0' ) ; carry = sum / 10 ; } for ( int i = n1 ; i < n2 ; i ++ ) { int sum = ( ( int ) ( str2 . charAt ( i ) - '0' ) + carry ) ; str += ( char ) ( sum % 10 + '0' ) ; carry = sum / 10 ; } if ( carry > 0 ) str += ( char ) ( carry + '0' ) ; str = new StringBuilder ( str ) . reverse ( ) . toString ( ) ; return str ; } public static void main ( String [ ] args ) { String str1 = "12" ; String str2 = "198111" ; System . out . println ( findSum ( str1 , str2 ) ) ; } }

Accumulator variables: i, str
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static String findSum ( String str1 , String str2 ) { if ( str1 . length ( ) > str2 . length ( ) ) { String t = str1 ; str1 = str2 ; str2 = t ; } String str = " " ; int n1 = str1 . length ( ) , n2 = str2 . length ( ) ; int diff = n2 - n1 ; int carry = 0 ; for ( int i = n1 - 1 ; i >= 0 ; i -- ) { int sum = ( ( int ) ( str1 . charAt ( i ) - '0' ) + ( int ) ( str2 . charAt ( i + diff ) - '0' ) + carry ) ; str += ( char ) ( sum % 10 + '0' ) ; carry = sum / 10 ; } for ( int i = n2 - n1 - 1 ; i >= 0 ; i -- ) { int sum = ( ( int ) ( str2 . charAt ( i ) - '0' ) + carry ) ; str += ( char ) ( sum % 10 + '0' ) ; carry = sum / 10 ; } if ( carry > 0 ) str += ( char ) ( carry + '0' ) ; return new StringBuilder ( str ) . reverse ( ) . toString ( ) ; } public static void main ( String [ ] args ) { String str1 = "12" ; String str2 = "198111" ; System . out . println ( findSum ( str1 , str2 ) ) ; } }

Accumulator variables: i, str
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . Arrays ; import java . util . List ; public class Palin_pair1 { static boolean isPalindrome ( String str ) { int len = str . length ( ) ; for ( int i = 0 ; i < len / 2 ; i ++ ) if ( str . charAt ( i ) != str . charAt ( len - i - 1 ) ) return false ; return true ; } static boolean checkPalindromePair ( List < String > vect ) { for ( int i = 0 ; i < vect . size ( ) - 1 ; i ++ ) { for ( int j = i + 1 ; j < vect . size ( ) ; j ++ ) { String check_str = " " ; check_str = check_str + vect . get ( i ) + vect . get ( j ) ; if ( isPalindrome ( check_str ) ) return true ; check_str = vect . get ( j ) + vect . get ( i ) ; if ( isPalindrome ( check_str ) ) return true ; } } return false ; } public static void main ( String args [ ] ) { List < String > vect = Arrays . asList ( " geekf " , " geeks " , " or " , " keeg " , " abc " , " bc " ) ; if ( checkPalindromePair ( vect ) == true ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: Palin_pair1
Java program:
class GFG { static void print ( String str1 ) { char str [ ] = str1 . toCharArray ( ) ; System . out . print ( str [ 0 ] ) ; for ( int i = 1 ; i < str . length ; i ++ ) { if ( ( str [ i ] == str [ i - 1 ] + 1 ) || ( str [ i ] == str [ i - 1 ] - 1 ) ) { System . out . print ( str [ i ] ) ; } else { System . out . print ( "NEW_LINE" + str[i]); } } } public static void main ( String [ ] args ) { String str = " ABCXYZACCD " ; print ( str ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static boolean areChractersUnique ( String str ) { int checker = 0 ; for ( int i = 0 ; i < str . length ( ) ; ++ i ) { int val = ( str . charAt ( i ) - ' a ' ) ; if ( ( checker & ( 1 << val ) ) > 0 ) return false ; checker |= ( 1 << val ) ; } return true ; } public static void main ( String [ ] args ) { String s = " aaabbccdaa " ; if ( areChractersUnique ( s ) ) System . out . print ( " Yes " ) ; else System . out . print ( " No " ) ; } }

Accumulator variables: checker
Iterator variables: i
Class/struct names: GFG
Java program:
public class GFG { static int countWords ( String str , int len ) { int count = 1 ; if ( len == 1 ) return count ; if ( str . charAt ( 0 ) == str . charAt ( 1 ) ) count *= 1 ; else count *= 2 ; for ( int j = 1 ; j < len - 1 ; j ++ ) { if ( str . charAt ( j ) == str . charAt ( j - 1 ) && str . charAt ( j ) == str . charAt ( j + 1 ) ) count *= 1 ; else if ( str . charAt ( j ) == str . charAt ( j - 1 ) || str . charAt ( j ) == str . charAt ( j + 1 ) || str . charAt ( j - 1 ) == str . charAt ( j + 1 ) ) count *= 2 ; else count *= 3 ; } if ( str . charAt ( len - 1 ) == str . charAt ( len - 2 ) ) count *= 1 ; else count *= 2 ; return count ; } public static void main ( String args [ ] ) { String str = " abc " ; int len = str . length ( ) ; System . out . println ( countWords ( str , len ) ) ; } }

Accumulator variables: count, j
Iterator variables: j
Class/struct names: GFG
Java program:
class GFG { static int replaceDig ( int x , int from , int to ) { int result = 0 ; int multiply = 1 ; while ( x > 0 ) { int reminder = x % 10 ; if ( reminder == from ) result = result + to * multiply ; else result = result + reminder * multiply ; multiply *= 10 ; x = x / 10 ; } return result ; } static void calculateMinMaxSum ( int x1 , int x2 ) { int minSum = replaceDig ( x1 , 6 , 5 ) + replaceDig ( x2 , 6 , 5 ) ; int maxSum = replaceDig ( x1 , 5 , 6 ) + replaceDig ( x2 , 5 , 6 ) ; System . out . print ( " Minimum ▁ sum ▁ = ▁ " + minSum ) ; System . out . print ( " Maximum sum = " + maxSum); } public static void main ( String [ ] args ) { int x1 = 5466 , x2 = 4555 ; calculateMinMaxSum ( x1 , x2 ) ; } }

Accumulator variables: multiply
Class/struct names: GFG
Java program:
class GFG { static void qType1 ( int l , int x , char str [ ] ) { str [ l - 1 ] = ( char ) x ; } static void qType2 ( int l , int r , char str [ ] ) { int freq [ ] = new int [ 27 ] ; for ( int i = l - 1 ; i <= r - 1 ; i ++ ) { freq [ str [ i ] - ' a ' ] ++ ; } int count = 0 ; for ( int j = 0 ; j < 26 ; j ++ ) { if ( freq [ j ] % 2 != 0 ) { count ++ ; } } if ( count <= 1 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } public static void main ( String [ ] args ) { char str [ ] = " geeksforgeeks " . toCharArray ( ) ; int n = str . length ; qType1 ( 4 , ' g ' , str ) ; qType2 ( 1 , 4 , str ) ; qType2 ( 2 , 3 , str ) ; qType1 ( 10 , ' t ' , str ) ; qType2 ( 10 , 11 , str ) ; } }

Index/key variables: i, j
Accumulator variables: count, i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int max = 1000 ; static int getFrequency ( int tree [ ] [ ] , int idx , int i ) { int sum = 0 ; while ( idx > 0 ) { sum += tree [ idx ] [ i ] ; idx -= ( idx & - idx ) ; } return sum ; } static void update ( int tree [ ] [ ] , int idx , int val , int i ) { while ( idx <= max ) { tree [ idx ] [ i ] += val ; idx += ( idx & - idx ) ; } } static void qType1 ( int tree [ ] [ ] , int l , int x , char str [ ] ) { update ( tree , l , - 1 , str [ l - 1 ] - 97 + 1 ) ; str [ l - 1 ] = ( char ) x ; update ( tree , l , 1 , str [ l - 1 ] - 97 + 1 ) ; } static void qType2 ( int tree [ ] [ ] , int l , int r , char str [ ] ) { int count = 0 ; for ( int i = 1 ; i <= 26 ; i ++ ) { if ( l == 1 ) { if ( getFrequency ( tree , r , i ) % 2 == 1 ) count ++ ; } else { if ( ( getFrequency ( tree , r , i ) - getFrequency ( tree , l - 1 , i ) ) % 2 == 1 ) count ++ ; } } if ( count <= 1 ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } static void buildBIT ( int tree [ ] [ ] , char str [ ] , int n ) { for ( int i = 0 ; i < n ; i ++ ) update ( tree , i + 1 , 1 , str [ i ] - 97 + 1 ) ; } public static void main ( String [ ] args ) { char str [ ] = " geeksforgeeks " . toCharArray ( ) ; int n = str . length ; int tree [ ] [ ] = new int [ max ] [ 27 ] ; buildBIT ( tree , str , n ) ; qType1 ( tree , 4 , ' g ' , str ) ; qType2 ( tree , 1 , 4 , str ) ; qType2 ( tree , 2 , 3 , str ) ; qType1 ( tree , 10 , ' t ' , str ) ; qType2 ( tree , 10 , 11 , str ) ; } }

Index/key variables: i, idx, max
Accumulator variables: count, i, idx, sum
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static void findDivision ( String str , int a , int b ) { int len = str . length ( ) ; int [ ] lr = new int [ len + 1 ] ; lr [ 0 ] = ( ( int ) str . charAt ( 0 ) - ( int ) '0' ) % a ; for ( int i = 1 ; i < len ; i ++ ) lr [ i ] = ( ( lr [ i - 1 ] * 10 ) % a + ( ( int ) str . charAt ( i ) - ( int ) '0' ) ) % a ; int [ ] rl = new int [ len + 1 ] ; rl [ len - 1 ] = ( ( int ) str . charAt ( len - 1 ) - ( int ) '0' ) % b ; int power10 = 10 ; for ( int i = len - 2 ; i >= 0 ; i -- ) { rl [ i ] = ( rl [ i + 1 ] + ( ( int ) str . charAt ( i ) - ( int ) '0' ) * power10 ) % b ; power10 = ( power10 * 10 ) % b ; } for ( int i = 0 ; i < len - 1 ; i ++ ) { if ( lr [ i ] != 0 ) continue ; if ( rl [ i + 1 ] == 0 ) { System . out . println ( " YES " ) ; for ( int k = 0 ; k <= i ; k ++ ) System . out . print ( str . charAt ( k ) ) ; System . out . print ( " , ▁ " ) ; for ( int k = i + 1 ; k < len ; k ++ ) System . out . print ( str . charAt ( k ) ) ; return ; } } System . out . println ( " NO " ) ; } public static void main ( String [ ] args ) { String str = "123" ; int a = 12 , b = 3 ; findDivision ( str , a , b ) ; } }

Index/key variables: i
Accumulator variables: i, k
Iterator variables: i, k
Class/struct names: GFG
Java program:
class Test { static String findTwoscomplement ( StringBuffer str ) { int n = str . length ( ) ; int i ; for ( i = n - 1 ; i >= 0 ; i -- ) if ( str . charAt ( i ) == '1' ) break ; if ( i == - 1 ) return "1" + str ; for ( int k = i - 1 ; k >= 0 ; k -- ) { if ( str . charAt ( k ) == '1' ) str . replace ( k , k + 1 , "0" ) ; else str . replace ( k , k + 1 , "1" ) ; } return str . toString ( ) ; } public static void main ( String [ ] args ) { StringBuffer str = new StringBuffer ( "00000101" ) ; System . out . println ( findTwoscomplement ( str ) ) ; } }

Accumulator variables: i, k
Iterator variables: i, k
Class/struct names: Test
Java program:
import java . io . * ; class GFG { static boolean isequal ( String str ) { int n = str . length ( ) ; int num = 0 , x = 1 , i = n - 1 ; for ( i = n - 1 ; i >= 0 ; i -- ) { if ( '0' <= str . charAt ( i ) && str . charAt ( i ) <= '9' ) { num = ( str . charAt ( i ) - '0' ) * x + num ; x = x * 10 ; if ( num >= n ) return false ; } else break ; } return num == i + 1 ; } static public void main ( String [ ] args ) { String str = " geeksforgeeks13" ; if ( isequal ( str ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { public static boolean kAnagrams ( String str1 , String str2 , int k ) { int flag = 0 ; List < Character > list = new ArrayList < > ( ) ; if ( str1 . length ( ) != str2 . length ( ) ) System . exit ( 0 ) ; char arr1 [ ] = str1 . toCharArray ( ) ; char arr2 [ ] = str2 . toCharArray ( ) ; Arrays . sort ( arr1 ) ; Arrays . sort ( arr2 ) ; for ( int i = 0 ; i < str1 . length ( ) ; i ++ ) { if ( arr1 [ i ] != arr2 [ i ] ) { list . add ( arr2 [ i ] ) ; } } if ( list . size ( ) <= k ) flag = 1 ; if ( flag == 1 ) return true ; else return false ; } public static void main ( String [ ] args ) { String str1 = " fodr " ; String str2 = " gork " ; int k = 2 ; kAnagrams ( str1 , str2 , k ) ; if ( kAnagrams ( str1 , str2 , k ) == true ) 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 . io . * ; public class GFG { static int countToMake0lternate ( String s ) { int result = 0 ; for ( int i = 0 ; i < ( s . length ( ) - 1 ) ; i ++ ) if ( s . charAt ( i ) == s . charAt ( i + 1 ) ) return result ; } static public void main ( String [ ] args ) { System . out . println ( countToMake0lternate ( "000111" ) ) ; System . out . println ( countToMake0lternate ( "11111" ) ) ; System . out . println ( countToMake0lternate ( "01010101" ) ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . HashMap ; import java . util . Iterator ; class GFG { static boolean checkString ( String str , int k ) { int n = str . length ( ) ; if ( n % k != 0 ) return false ; HashMap < String , Integer > mp = new HashMap < > ( ) ; try { for ( int i = 0 ; i < n ; i += k ) mp . put ( str . substring ( i , k ) , mp . get ( str . substring ( i , k ) ) == null ? 1 : mp . get ( str . substring ( i , k ) ) + 1 ) ; } catch ( Exception e ) { } if ( mp . size ( ) == 1 ) return true ; if ( mp . size ( ) != 2 ) return false ; HashMap . Entry < String , Integer > entry = mp . entrySet ( ) . iterator ( ) . next ( ) ; if ( entry . getValue ( ) == ( n / k - 1 ) || entry . getValue ( ) == 1 ) return true ; return false ; } public static void main ( String [ ] args ) { if ( checkString ( " abababcd " , 2 ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class Test { static final int MAX_CHAR = 26 ; static void printGrouped ( String str ) { int n = str . length ( ) ; int count [ ] = new int [ MAX_CHAR ] ; for ( int i = 0 ; i < n ; i ++ ) count [ str . charAt ( i ) - ' a ' ] ++ ; for ( int i = 0 ; i < n ; i ++ ) { while ( count [ str . charAt ( i ) - ' a ' ] != 0 ) { System . out . print ( str . charAt ( i ) ) ; count [ str . charAt ( i ) - ' a ' ] -- ; } count [ str . charAt ( i ) - ' a ' ] = 0 ; } } public static void main ( String args [ ] ) { String str = new String ( " geeksforgeeks " ) ; printGrouped ( str ) ; } }

Index/key variables: MAX_CHAR
Accumulator variables: i
Iterator variables: i
Class/struct names: Test