dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
class GFG { static String build_binary_str ( int p , int q , int r ) { String ans = " " ; if ( q == 0 ) { if ( p != 0 && r != 0 ) { return " - 1" ; } else { if ( p > 0 ) { ans = Strings ( p + 1 , '0' ) ; } else { ans = Strings ( r + 1 , '1' ) ; } } } else { for ( int i = 1 ; i <= q + 1 ; i ++ ) { if ( i % 2 == 0 ) { ans += '0' ; } else { ans += '1' ; } } ans = ans . substring ( 0 , 1 ) + Strings ( p , '0' ) + ans . substring ( 1 ) ; ans = Strings ( r , '1' ) + ans ; } return ans ; } static String Strings ( int p , char c ) { String ans = " " ; for ( int i = 0 ; i < p ; i ++ ) ans += c ; return ans ; } public static void main ( String [ ] args ) { int p = 1 , q = 2 , r = 2 ; System . out . print ( build_binary_str ( p , q , r ) ) ; } }

Accumulator variables: ans, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { static boolean check ( String s ) { boolean ok = true ; for ( int i = 0 ; i + 1 < s . length ( ) ; ++ i ) ok &= ( Math . abs ( s . charAt ( i ) - s . charAt ( i + 1 ) ) != 1 ) ; return ok ; } static String monotonousString ( String s ) { String odd = " " , even = " " ; for ( int i = 0 ; i < s . length ( ) ; ++ i ) { if ( s . charAt ( i ) % 2 == 0 ) odd += s . charAt ( i ) ; else even += s . charAt ( i ) ; } char oddArray [ ] = odd . toCharArray ( ) ; Arrays . sort ( oddArray ) ; odd = new String ( oddArray ) ; char evenArray [ ] = even . toCharArray ( ) ; Arrays . sort ( evenArray ) ; even = new String ( evenArray ) ; if ( check ( odd + even ) ) return " Yes " ; else if ( check ( even + odd ) ) return " Yes " ; return " No " ; } public static void main ( String [ ] args ) { String str = " abcd " ; String ans ; ans = monotonousString ( str ) ; System . out . println ( ans ) ; } }

Accumulator variables: even, odd, ok
Iterator variables: i
Boolean variables: ok
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int get_index ( char ch ) { if ( ch == ' a ' ) return 0 ; else if ( ch == ' e ' ) return 1 ; else if ( ch == ' i ' ) return 2 ; else if ( ch == ' o ' ) return 3 ; else if ( ch == ' u ' ) return 4 ; else return - 1 ; } static int findMinLength ( String s ) { int n = s . length ( ) ; int ans = n + 1 ; int start = 0 ; int count [ ] = new int [ 5 ] ; for ( int x = 0 ; x < n ; x ++ ) { int idx = get_index ( s . charAt ( x ) ) ; if ( idx != - 1 ) { count [ idx ] ++ ; } int idx_start = get_index ( s . charAt ( start ) ) ; while ( idx_start == - 1 count [ idx_start ] > 1 ) { if ( idx_start != - 1 ) { count [ idx_start ] -- ; } start ++ ; if ( start < n ) idx_start = get_index ( s . charAt ( start ) ) ; } if ( count [ 0 ] > 0 && count [ 1 ] > 0 && count [ 2 ] > 0 && count [ 3 ] > 0 && count [ 4 ] > 0 ) { ans = Math . min ( ans , x - start + 1 ) ; } } if ( ans == n + 1 ) return - 1 ; return ans ; } public static void main ( String [ ] args ) { String s = " aaeebbeaccaaoiuooooooooiuu " ; System . out . print ( findMinLength ( s ) ) ; } }

Index/key variables: idx, idx_start
Accumulator variables: start, x
Iterator variables: x
Class/struct names: GFG
Java program:
class GFG { static int countStrings ( String s ) { int cnt = 0 ; for ( int i = 1 ; i < s . length ( ) - 1 ; i ++ ) { if ( s . charAt ( i ) == s . charAt ( i + 1 ) ) { cnt ++ ; } } return cnt ; } public static void main ( String [ ] args ) { String str = " aacbb " ; System . out . println ( countStrings ( str ) ) ; } }

Accumulator variables: cnt, i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static boolean checkValidString ( String str ) { int freq [ ] = new int [ 26 ] ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { freq [ str . charAt ( i ) - ' a ' ] ++ ; } for ( int i = 0 ; i < 26 ; i ++ ) { if ( freq [ i ] != 0 ) { if ( freq [ i ] != i + 1 ) { return false ; } } } return true ; } public static void main ( String [ ] args ) { String str = " abbcccdddd " ; if ( checkValidString ( str ) ) { 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:
class GFG { static void removeRepeating ( String s1 , String s2 ) { String s3 = s1 + " ▁ " + s2 + " ▁ " ; String words = " " ; int i = 0 ; for ( char x : s3 . toCharArray ( ) ) { if ( x == ' ▁ ' ) { if ( ! s1 . contains ( words ) || ! s2 . contains ( words ) ) System . out . print ( words ) ; words = " ▁ " ; } else { words = words + x ; } } } public static void main ( String [ ] args ) { String s1 = " I ▁ have ▁ go ▁ a ▁ pen " ; String s2 = " I ▁ want ▁ to ▁ go ▁ park " ; removeRepeating ( s1 , s2 ) ; } }

Iterator variables: x
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static String convert ( String input ) { StringBuilder sbInput = new StringBuilder ( input ) ; int len = sbInput . length ( ) ; for ( int i = 0 ; i < len ; ) { if ( sbInput . charAt ( i ) == ' , ' ) { sbInput . deleteCharAt ( i ) ; len -- ; i -- ; } else if ( sbInput . charAt ( i ) == ' ▁ ' ) { sbInput . deleteCharAt ( i ) ; len -- ; i -- ; } else { i ++ ; } } StringBuilder sbInputReverse = sbInput . reverse ( ) ; StringBuilder output = new StringBuilder ( ) ; for ( int i = 0 ; i < len ; i ++ ) { if ( i == 2 ) { output . append ( sbInputReverse . charAt ( i ) ) ; output . append ( " ▁ , " ) ; } else if ( i > 2 && i % 2 == 0 && i + 1 < len ) { output . append ( sbInputReverse . charAt ( i ) ) ; output . append ( " ▁ , " ) ; } else { output . append ( sbInputReverse . charAt ( i ) ) ; } } StringBuilder reverseOutput = output . reverse ( ) ; return reverseOutput . toString ( ) ; } public static void main ( String [ ] args ) { String input1 = "123 , ▁ 456 , ▁ 789" ; String input2 = "90 , ▁ 050 , ▁ 000 , ▁ 000" ; System . out . println ( convert ( input1 ) ) ; System . out . println ( convert ( input2 ) ) ; } }

Accumulator variables: i, len
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static boolean isPrime ( int n ) { if ( n <= 1 ) return false ; for ( int i = 2 ; i <= Math . sqrt ( n ) ; i ++ ) { if ( n % i == 0 ) return false ; } return true ; } static boolean isPossibleSum ( int N ) { if ( isPrime ( N ) && isPrime ( N - 2 ) ) { return true ; } else { return false ; } } static boolean checkSemiprime ( int num ) { int cnt = 0 ; for ( int i = 2 ; cnt < 2 && i * i <= num ; ++ i ) { while ( num % i == 0 ) { num /= i ; ++ cnt ; } } if ( num > 1 ) { ++ cnt ; } return cnt == 2 ; } static void makeCypherString ( int N ) { String semiPrime = " " ; String sumOfPrime = " " ; String str = String . valueOf ( N ) ; if ( checkSemiprime ( N ) ) { for ( int i = 0 ; i < str . length ( ) ; i ++ ) { if ( i % 2 == 1 ) { semiPrime += str . charAt ( i ) ; } else { semiPrime += ( char ) ( str . charAt ( i ) - '0' + 65 ) ; } } } if ( isPossibleSum ( N ) ) { for ( int i = 0 ; i < str . length ( ) ; i ++ ) { if ( i % 2 == 1 ) { sumOfPrime += ( char ) ( str . charAt ( i ) - '0' + 65 ) ; } else { sumOfPrime += str . charAt ( i ) ; } } } if ( semiPrime + sumOfPrime == " " ) { System . out . print ( " - 1" ) ; } else { System . out . print ( semiPrime + sumOfPrime ) ; } } public static void main ( String [ ] args ) { int N = 1011243 ; makeCypherString ( N ) ; } }

Accumulator variables: i, num, semiPrime, sumOfPrime
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { static void rearrange ( String str , int K ) { int n = str . length ( ) ; int s = 0 , sum = 0 , count = 0 ; for ( int i = n - 1 ; i >= 0 ; i -- ) { int a = str . charAt ( i ) - '0' ; sum += a * Math . pow ( 2 , s ) ; s ++ ; if ( sum != 0 && sum % K == 0 ) { count ++ ; sum = 0 ; s = 0 ; } } if ( sum != 0 ) System . out . println ( " - 1" ) ; else System . out . println ( count ) ; } public static void main ( String [ ] args ) { String str = "10111001" ; int K = 5 ; rearrange ( str , K ) ; } }

Accumulator variables: count, i, s, sum
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static String findStr ( String S ) { StringBuilder sb = new StringBuilder ( S ) ; int n = sb . length ( ) ; for ( int i = 0 ; i < n / 2 ; ++ i ) { if ( sb . charAt ( i ) != ' a ' ) { sb . setCharAt ( i , ' a ' ) ; return sb . toString ( ) ; } } sb . setCharAt ( n - 1 , ' b ' ) ; return n < 2 ? " ▁ - 1 ▁ " : sb . toString ( ) ; } public static void main ( String [ ] args ) { String str = " a " ; System . out . println ( findStr ( str ) ) ; String str1 = " abccba " ; System . out . println ( findStr ( str1 ) ) ; } }

Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static void kth_String ( int n , int k ) { for ( int i = n - 2 ; i >= 0 ; i -- ) { if ( k <= ( n - i - 1 ) ) { for ( int j = 0 ; j < n ; j ++ ) { if ( j == i j == n - k ) System . out . print ( ' Y ' ) ; else System . out . print ( ' X ' ) ; } break ; } k -= ( n - i - 1 ) ; } } public static void main ( String [ ] args ) { int n = 5 , k = 7 ; kth_String ( n , k ) ; } }

Accumulator variables: i, j, k
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void convertString ( String str1 , String str2 , String str3 ) { HashMap < Character , Integer > freq = new HashMap < > ( ) ; for ( int i = 0 ; i < str3 . length ( ) ; i ++ ) { if ( freq . containsKey ( str3 . charAt ( i ) ) ) freq . put ( str3 . charAt ( i ) , freq . get ( str3 . charAt ( i ) ) + 1 ) ; else freq . put ( str3 . charAt ( i ) , 1 ) ; } int ptr1 = 0 ; int ptr2 = 0 ; boolean flag = true ; while ( ptr1 < str1 . length ( ) && ptr2 < str2 . length ( ) ) { if ( str1 . charAt ( ptr1 ) == str2 . charAt ( ptr2 ) ) { ptr1 ++ ; ptr2 ++ ; } else { if ( freq . containsKey ( str3 . charAt ( ptr2 ) ) ) if ( freq . get ( str3 . charAt ( ptr2 ) ) > 0 ) { freq . put ( str3 . charAt ( ptr2 ) , freq . get ( str3 . charAt ( ptr2 ) ) - 1 ) ; ptr2 ++ ; } else { flag = false ; break ; } } } if ( flag && ptr1 == str1 . length ( ) && ptr2 == str2 . length ( ) ) { System . out . print ( " YES " + "NEW_LINE"); } else { System . out . print ( " NO " + "NEW_LINE"); } } public static void main ( String [ ] args ) { String str1 = " abyzfe " ; String str2 = " abcdeyzf " ; String str3 = " popode " ; convertString ( str1 , str2 , str3 ) ; } }

Accumulator variables: i, ptr1, ptr2
Iterator variables: i
Boolean variables: flag
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int MOD = 26 ; static int modulo_by_26 ( String num ) { int res = 0 ; for ( int i = 0 ; i < num . length ( ) ; i ++ ) { res = ( ( res * 10 + ( int ) num . charAt ( i ) - '0' ) % MOD ) ; } return res ; } static String decrypt_message ( String s ) { String decrypted_str = " " ; String num_found_so_far = " " ; for ( int i = 0 ; i < s . length ( ) ; ++ i ) { if ( s . charAt ( i ) >= '0' && s . charAt ( i ) <= '9' ) { num_found_so_far += s . charAt ( i ) ; } else if ( num_found_so_far . length ( ) > 0 ) { decrypted_str += ( char ) ( ' a ' + modulo_by_26 ( num_found_so_far ) ) ; num_found_so_far = " " ; } } if ( num_found_so_far . length ( ) > 0 ) { decrypted_str += ( char ) ( ' a ' + modulo_by_26 ( num_found_so_far ) ) ; } return decrypted_str ; } public static void main ( String [ ] args ) { String s = "32ytAAcV4ui30hf10hj18" ; System . out . print ( decrypt_message ( s ) ) ; } }

Accumulator variables: decrypted_str, i, num_found_so_far
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int maxOverlap ( String S , String T ) { String str = T ; int count [ ] = new int [ T . length ( ) ] ; int overlap = 0 ; int max_overlap = 0 ; for ( int i = 0 ; i < S . length ( ) ; i ++ ) { int index = str . indexOf ( S . charAt ( i ) ) ; if ( index == 0 ) { overlap ++ ; if ( overlap >= 2 ) max_overlap = Math . max ( overlap , max_overlap ) ; count [ index ] ++ ; } else { if ( count [ index - 1 ] <= 0 ) return - 1 ; count [ index ] ++ ; count [ index - 1 ] -- ; } if ( index == 4 ) overlap -- ; } if ( overlap == 0 ) return max_overlap ; else return - 1 ; } public static void main ( String [ ] args ) { String S = " chcirphirp " ; String T = " chirp " ; System . out . print ( maxOverlap ( S , T ) ) ; } }

Index/key variables: index
Accumulator variables: i, overlap
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static final int MAX = 500001 ; static int [ ] parent = new int [ MAX ] ; static int [ ] Rank = new int [ MAX ] ; static class pair { char first , second ; public pair ( char first , char second ) { this . first = first ; this . second = second ; } } static int find ( int x ) { return parent [ x ] = parent [ x ] == x ? x : find ( parent [ x ] ) ; } static void merge ( int r1 , int r2 ) { if ( r1 != r2 ) { if ( Rank [ r1 ] > Rank [ r2 ] ) { parent [ r2 ] = r1 ; Rank [ r1 ] += Rank [ r2 ] ; } else { parent [ r1 ] = r2 ; Rank [ r2 ] += Rank [ r1 ] ; } } } static void minimumOperations ( String s1 , String s2 ) { for ( int i = 1 ; i <= 26 ; i ++ ) { parent [ i ] = i ; Rank [ i ] = 1 ; } Vector < pair > ans = new Vector < pair > ( ) ; for ( int i = 0 ; i < s1 . length ( ) ; i ++ ) { if ( s1 . charAt ( i ) != s2 . charAt ( i ) ) { if ( find ( s1 . charAt ( i ) - 96 ) != find ( s2 . charAt ( i ) - 96 ) ) { int x = find ( s1 . charAt ( i ) - 96 ) ; int y = find ( s2 . charAt ( i ) - 96 ) ; merge ( x , y ) ; ans . add ( new pair ( s1 . charAt ( i ) , s2 . charAt ( i ) ) ) ; } } } System . out . print ( ans . size ( ) + "NEW_LINE"); for ( int i = 0 ; i < ans . size ( ) ; i ++ ) System . out . print ( ans . get ( i ) . first + " - > " + ans . get ( i ) . second + "NEW_LINE"); } public static void main ( String [ ] args ) { String s1 , s2 ; s1 = " abb " ; s2 = " dad " ; minimumOperations ( s1 , s2 ) ; } }

Index/key variables: MAX, i, r1, r2, x
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG, pair
Java program:
import java . util . * ; class GFG { static void String_permutation ( int n , String str ) { Stack < Integer > s = new Stack < Integer > ( ) ; String result = " " ; n = n - 1 ; for ( int i = 1 ; i < str . length ( ) + 1 ; i ++ ) { s . add ( n % i ) ; n = n / i ; } for ( int i = 0 ; i < str . length ( ) ; i ++ ) { int a = s . peek ( ) ; result += str . charAt ( a ) ; int j ; for ( j = a ; j < str . length ( ) - 1 ; j ++ ) str = str . substring ( 0 , j ) + str . charAt ( j + 1 ) + str . substring ( j + 1 ) ; str = str . substring ( 0 , j + 1 ) ; s . pop ( ) ; } System . out . print ( result + "NEW_LINE"); } public static void main ( String [ ] args ) { String str = " abcde " ; int n = 11 ; String_permutation ( n , str ) ; } }

Accumulator variables: i, j, result
Iterator variables: i, j
Class/struct names: GFG
Java program:
class GFG { static String GeberateDefangIP ( String str ) { String defangIP = " " ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { char c = str . charAt ( i ) ; if ( c == ' . ' ) { defangIP += " [ . ] " ; } else { defangIP += c ; } } return defangIP ; } public static void main ( String [ ] args ) { String str = "255.100.50.0" ; System . out . println ( GeberateDefangIP ( str ) ) ; } }

Accumulator variables: defangIP, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static String generateTheString ( int n ) { String ans = " " ; if ( n % 2 != 0 ) { for ( int i = 0 ; i < Math . min ( n , 24 ) ; i ++ ) { ans += ( char ) ( ' b ' + i ) ; } if ( n > 24 ) { for ( int i = 0 ; i < ( n - 24 ) ; i ++ ) ans += ' a ' ; } } else { for ( int i = 0 ; i < Math . min ( n , 25 ) ; i ++ ) { ans += ( char ) ( ' b ' + i ) ; } if ( n > 25 ) { for ( int i = 0 ; i < ( n - 25 ) ; i ++ ) ans += ' a ' ; } } return ans ; } public static void main ( String [ ] args ) { int n = 34 ; System . out . println ( generateTheString ( n ) ) ; } }

Accumulator variables: ans, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void moveAtEnd ( String s , int i , int l ) { if ( i >= l ) return ; char curr = s . charAt ( i ) ; if ( curr != ' x ' ) System . out . print ( curr ) ; moveAtEnd ( s , i + 1 , l ) ; if ( curr == ' x ' ) System . out . print ( curr ) ; return ; } public static void main ( String args [ ] ) { String s = " geekxsforgexxeksxx " ; int l = s . length ( ) ; moveAtEnd ( s , 0 , l ) ; } }

Class/struct names: GFG
Java program:
public class GFG { static void string ( int l , int x , int y ) { int p = 97 ; for ( int j = 0 ; j < l ; j ++ ) { char ans = ( char ) ( p + ( j % y ) ) ; System . out . print ( ans ) ; } } public static void main ( String [ ] args ) { int l = 6 ; int x = 5 ; int y = 3 ; string ( l , x , y ) ; } }

Accumulator variables: j
Iterator variables: j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void finalCoordinates ( int SX , int SY , char [ ] D ) { for ( int i = 0 ; i < D . length ; i ++ ) { if ( D [ i ] == ' N ' ) SY += 1 ; else if ( D [ i ] == ' S ' ) SY -= 1 ; else if ( D [ i ] == ' E ' ) SX += 1 ; else SX -= 1 ; } String ans = ' ( ' + String . valueOf ( SX ) + ' , ' + String . valueOf ( SY ) + ' ) ' ; System . out . print ( ans ) ; } public static void main ( String [ ] args ) { int SX = 2 , SY = 2 ; String D = " NSSE " ; finalCoordinates ( SX , SY , D . toCharArray ( ) ) ; } }

Index/key variables: i
Accumulator variables: SX, SY, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { static int countMinFreq ( String s ) { char [ ] tempArray = s . toCharArray ( ) ; Arrays . sort ( tempArray ) ; s = new String ( tempArray ) ; int x = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) if ( s . charAt ( i ) == s . charAt ( 0 ) ) x ++ ; return x ; } static void countLessThan ( List < String > arr1 , List < String > arr2 ) { List < Integer > freq = new ArrayList < Integer > ( ) ; for ( String s : arr2 ) { int f = countMinFreq ( s ) ; freq . add ( f ) ; } Collections . sort ( freq ) ; for ( String s : arr1 ) { int f = countMinFreq ( s ) ; int it = upper_bound ( freq , f ) ; int cnt = freq . size ( ) - it ; System . out . print ( cnt + " ▁ " ) ; } } static int upper_bound ( List < Integer > freq , int f ) { int low = 0 , high = freq . size ( ) - 1 ; while ( low < high ) { int mid = ( low + high ) / 2 ; if ( freq . get ( mid ) > f ) high = mid ; else low = mid + 1 ; } return ( freq . get ( low ) < f ) ? low ++ : low ; } public static void main ( String [ ] args ) { List < String > arr1 , arr2 ; arr1 = Arrays . asList ( new String [ ] { " yyy " , " zz " } ) ; arr2 = Arrays . asList ( new String [ ] { " x " , " xx " , " xxx " , " xxxx " } ) ; countLessThan ( arr1 , arr2 ) ; } }

Accumulator variables: i, low, x
Iterator variables: i, s
Class/struct names: GFG
Java program:
class Main { static void shortestPalindrome ( String s ) { int [ ] abcd = new int [ 26 ] ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) abcd [ s . charAt ( i ) - 97 ] = 1 ; for ( int i = 0 ; i < 26 ; i ++ ) { if ( abcd [ i ] == 1 ) { System . out . print ( ( char ) ( i + 97 ) + " ▁ " ) ; } } } public static void main ( String [ ] args ) { String s = " geeksforgeeks " ; shortestPalindrome ( s ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: Main
Java program:
import java . util . * ; class GFG { static String removeDuplicates ( String str ) { int n = str . length ( ) ; String res = " " ; for ( int i = 0 ; i < n ; i ++ ) { int j ; for ( j = i + 1 ; j < n ; j ++ ) if ( str . charAt ( i ) == str . charAt ( j ) ) break ; if ( j == n ) res = res + str . charAt ( i ) ; } return res ; } public static void main ( String [ ] args ) { String str = " geeksforgeeks " ; System . out . print ( removeDuplicates ( str ) ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static String removeDuplicates ( String str ) { int n = str . length ( ) ; HashSet < Character > s = new HashSet < Character > ( ) ; String res = " " ; for ( int i = n - 1 ; i >= 0 ; i -- ) { if ( ! s . contains ( str . charAt ( i ) ) ) { res = res + str . charAt ( i ) ; s . add ( str . charAt ( i ) ) ; } } res = reverse ( res ) ; return res ; } static String reverse ( String input ) { char [ ] a = input . toCharArray ( ) ; int l , r = a . length - 1 ; for ( l = 0 ; l < r ; l ++ , r -- ) { char temp = a [ l ] ; a [ l ] = a [ r ] ; a [ r ] = temp ; } return String . valueOf ( a ) ; } public static void main ( String [ ] args ) { String str = " geeksforgeeks " ; System . out . print ( removeDuplicates ( str ) ) ; } }

Index/key variables: l, r
Accumulator variables: i, l, r
Iterator variables: i, l
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void contain ( int L , int U , int M ) { int count = 0 ; for ( int j = L ; j < U ; j ++ ) { HashSet < String > num = new HashSet < > ( ) ; String str = Integer . toString ( j ) ; num . add ( str ) ; if ( j % M == 0 && ! num . contains ( Integer . toString ( M ) ) ) { count += 1 ; } } System . out . println ( count - 2 ) ; } public static void main ( String [ ] args ) { int L = 106 ; int U = 200 ; int M = 7 ; contain ( L , U , M ) ; } }

Accumulator variables: count, j
Iterator variables: j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int max1 = 0 ; static int MaxLength ( Vector < String > v , int i , int m ) { if ( i >= m ) { return m - 1 ; } for ( int k = 0 ; k < 26 ; k ++ ) { char c = ( char ) ( ' a ' + k ) ; Vector < String > v1 = new Vector < String > ( ) ; for ( int j = 0 ; j < v . size ( ) ; j ++ ) { if ( v . get ( j ) . charAt ( i ) == c ) { v1 . add ( v . get ( j ) ) ; } } if ( v1 . size ( ) >= 2 ) { max1 = Math . max ( max1 , MaxLength ( v1 , i + 1 , m ) ) ; } else { max1 = Math . max ( max1 , i - 1 ) ; } } return max1 ; } public static void main ( String [ ] args ) { String s1 , s2 , s3 , s4 , s5 ; s1 = " abcde " ; s2 = " abcsd " ; s3 = " bcsdf " ; s4 = " abcda " ; s5 = " abced " ; Vector < String > v = new Vector < String > ( ) ; v . add ( s1 ) ; v . add ( s2 ) ; v . add ( s3 ) ; v . add ( s4 ) ; v . add ( s5 ) ; int m = v . get ( 0 ) . length ( ) ; System . out . print ( MaxLength ( v , 0 , m ) + 1 ) ; } }

Accumulator variables: j, k
Iterator variables: j, k
Class/struct names: GFG
Java program:
class GFG { static void findPeriodicString ( String S ) { int l = 2 * S . length ( ) ; int count = 0 ; for ( int i = 0 ; i < S . length ( ) ; i ++ ) { if ( S . charAt ( i ) == '1' ) count ++ ; } if ( count == S . length ( ) count == 0 ) System . out . println ( S ) ; else { char arr [ ] = new char [ l ] ; for ( int i = 0 ; i < l ; i += 2 ) { arr [ i ] = '1' ; arr [ i + 1 ] = '0' ; } for ( int i = 0 ; i < l ; i ++ ) System . out . print ( arr [ i ] ) ; System . out . println ( ) ; } } public static void main ( String [ ] args ) { String S = "1111001" ; findPeriodicString ( S ) ; } }

Index/key variables: i, l
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; import java . lang . * ; class GFG { static boolean compare ( StringBuilder s , StringBuilder t ) { int ps , pt , i ; ps = - 1 ; for ( i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == ' # ' && ps != - 1 ) ps -= 1 ; else if ( s . charAt ( i ) != ' # ' ) { s . setCharAt ( ps + 1 , s . charAt ( i ) ) ; ps += 1 ; } } pt = - 1 ; for ( i = 0 ; i < t . length ( ) ; i ++ ) { if ( t . charAt ( i ) == ' # ' && pt != - 1 ) pt -= 1 ; else if ( t . charAt ( i ) != ' # ' ) { t . setCharAt ( pt + 1 , t . charAt ( i ) ) ; pt += 1 ; } } if ( pt != ps ) return false ; else if ( ps == - 1 && pt == - 1 ) return true ; else { for ( i = 0 ; i <= pt ; i ++ ) { if ( s . charAt ( i ) != t . charAt ( i ) ) return false ; } return true ; } } public static void main ( String [ ] args ) { StringBuilder s = new StringBuilder ( " geee # e # ks " ) ; StringBuilder t = new StringBuilder ( " gee # # eeks " ) ; if ( compare ( s , t ) ) System . out . print ( " True " ) ; else System . out . print ( " False " ) ; } }

Accumulator variables: i, ps, pt
Iterator variables: i
Class/struct names: GFG