dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
import java . util . HashSet ; public class GFG { static boolean isVowel ( char x ) { return ( x == ' a ' x == ' e ' x == ' i ' x == ' o ' x == ' u ' ) ; } static void findSubstring ( String str ) { HashSet < Character > hash = new HashSet < Character > ( ) ; int n = str . length ( ) ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i ; j < n ; j ++ ) { if ( isVowel ( str . charAt ( j ) ) == false ) break ; hash . add ( str . charAt ( j ) ) ; if ( hash . size ( ) == 5 ) System . out . print ( str . substring ( i , j + 1 ) + " ▁ " ) ; } hash . clear ( ) ; } } public static void main ( String [ ] args ) { String str = " aeoibsddaeiouudb " ; findSubstring ( str ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static boolean check ( Vector < String > list , String s ) { int n = ( int ) list . size ( ) ; if ( n == 0 ) { return false ; } for ( int i = 0 ; i < n ; i ++ ) { if ( list . get ( i ) . length ( ) != s . length ( ) ) { continue ; } boolean diff = false ; for ( int j = 0 ; j < ( int ) list . get ( i ) . length ( ) ; j ++ ) { if ( list . get ( i ) . charAt ( j ) != s . charAt ( j ) ) { if ( ! diff ) { diff = true ; } else { diff = false ; break ; } } } if ( diff ) { return true ; } } return false ; } public static void main ( String [ ] args ) { Vector < String > s = new Vector < > ( ) ; s . add ( " bana " ) ; s . add ( " apple " ) ; s . add ( " banacb " ) ; s . add ( " bonanza " ) ; s . add ( " banamf " ) ; System . out . println ( check ( s , " banana " ) == true ? 1 : 0 ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Boolean variables: diff
Class/struct names: GFG
Java program:
public class GFG { static boolean sentencePalindrome ( String str ) { int l = 0 ; int h = str . length ( ) - 1 ; str = str . toLowerCase ( ) ; while ( l <= h ) { char getAtl = str . charAt ( l ) ; char getAth = str . charAt ( h ) ; if ( ! ( getAtl >= ' a ' && getAtl <= ' z ' ) ) l ++ ; else if ( ! ( getAth >= ' a ' && getAth <= ' z ' ) ) h -- ; else if ( getAtl == getAth ) { l ++ ; h -- ; } else return false ; } return true ; } public static void main ( String [ ] args ) { String str = " Too ▁ hot ▁ to ▁ hoot . " ; if ( sentencePalindrome ( str ) ) System . out . println ( " Sentence ▁ is ▁ palindrome " ) ; else System . out . println ( " Sentence ▁ is ▁ not " + " ▁ " + " palindrome " ) ; } }

Accumulator variables: h, l
Class/struct names: GFG
Java program:
import java . util . * ; class CountWays { static int xorZero ( String s ) { int one_count = 0 , zero_count = 0 ; char [ ] str = s . toCharArray ( ) ; int n = str . length ; for ( int i = 0 ; i < n ; i ++ ) if ( str [ i ] == '1' ) one_count ++ ; else zero_count ++ ; if ( one_count % 2 == 0 ) return zero_count ; return one_count ; } public static void main ( String [ ] args ) { String s = "11111" ; System . out . println ( xorZero ( s ) ) ; } }

Index/key variables: i
Accumulator variables: i, one_count, zero_count
Iterator variables: i
Class/struct names: CountWays
Java program:
class GFG { static String encoder ( char [ ] key ) { String encoded = " " ; boolean [ ] arr = new boolean [ 26 ] ; for ( int i = 0 ; i < key . length ; i ++ ) { if ( key [ i ] >= ' A ' && key [ i ] <= ' Z ' ) { if ( arr [ key [ i ] - 65 ] == false ) { encoded += ( char ) key [ i ] ; arr [ key [ i ] - 65 ] = true ; } } else if ( key [ i ] >= ' a ' && key [ i ] <= ' z ' ) { if ( arr [ key [ i ] - 97 ] == false ) { encoded += ( char ) ( key [ i ] - 32 ) ; arr [ key [ i ] - 97 ] = true ; } } } for ( int i = 0 ; i < 26 ; i ++ ) { if ( arr [ i ] == false ) { arr [ i ] = true ; encoded += ( char ) ( i + 65 ) ; } } return encoded ; } static String cipheredIt ( String msg , String encoded ) { String cipher = " " ; for ( int i = 0 ; i < msg . length ( ) ; i ++ ) { if ( msg . charAt ( i ) >= ' a ' && msg . charAt ( i ) <= ' z ' ) { int pos = msg . charAt ( i ) - 97 ; cipher += encoded . charAt ( pos ) ; } else if ( msg . charAt ( i ) >= ' A ' && msg . charAt ( i ) <= ' Z ' ) { int pos = msg . charAt ( i ) - 65 ; cipher += encoded . charAt ( pos ) ; } else { cipher += msg . charAt ( i ) ; } } return cipher ; } public static void main ( String [ ] args ) { String key ; key = " Computer " ; System . out . println ( " Keyword ▁ : ▁ " + key ) ; String encoded = encoder ( key . toCharArray ( ) ) ; String message = " GeeksforGeeks " ; System . out . println ( " Message ▁ before ▁ Ciphering ▁ : ▁ " + message ) ; System . out . println ( " Ciphered ▁ Text ▁ : ▁ " + cipheredIt ( message , encoded ) ) ; } }

Index/key variables: i
Accumulator variables: cipher, encoded, i
Iterator variables: i
Class/struct names: GFG
Java program:
public class GFG { static final int MAX_CHAR = 26 ; static boolean checkCorrectOrNot ( String s ) { int [ ] count = new int [ MAX_CHAR ] ; int n = s . length ( ) ; if ( n == 1 ) return true ; for ( int i = 0 , j = n - 1 ; i < j ; i ++ , j -- ) { count [ s . charAt ( i ) - ' a ' ] ++ ; count [ s . charAt ( j ) - ' a ' ] -- ; } for ( int i = 0 ; i < MAX_CHAR ; i ++ ) if ( count [ i ] != 0 ) return false ; return true ; } public static void main ( String args [ ] ) { String s = " abab " ; if ( checkCorrectOrNot ( s ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } }

Index/key variables: MAX_CHAR, i
Accumulator variables: i, j
Iterator variables: i
Class/struct names: GFG
Java program:
class Test { static boolean checkString ( String s ) { int len = s . length ( ) ; int first = 0 ; for ( int i = 0 ; i < len ; i ++ ) { if ( s . charAt ( i ) == '1' ) { first = i ; break ; } } int last = 0 ; for ( int i = len - 1 ; i >= 0 ; i -- ) { if ( s . charAt ( i ) == '1' ) { last = i ; break ; } } for ( int i = first ; i <= last ; i ++ ) if ( s . charAt ( i ) == '0' ) return false ; return true ; } public static void main ( String args [ ] ) { String s = "00011111111100000" ; System . out . println ( checkString ( s ) ? " VALID " : " NOT ▁ VALID " ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: Test
Java program:
import java . io . * ; class GFG { public static void printAllSubStrings ( String s , int n ) { for ( int i = 0 ; i < n ; i ++ ) { char [ ] temp = new char [ n - i + 1 ] ; int tempindex = 0 ; for ( int j = i ; j < n ; j ++ ) { temp [ tempindex ++ ] = s . charAt ( j ) ; temp [ tempindex ] = ' \0' ; System . out . println ( temp ) ; } } } public static void main ( String [ ] args ) { String s = " Geeky " ; printAllSubStrings ( s , s . length ( ) ) ; } }

Index/key variables: tempindex
Accumulator variables: i, j, tempindex
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { public static void preserveSpace ( String str ) { int n = str . length ( ) ; int start = 0 ; int end = n - 1 ; char [ ] Str = str . toCharArray ( ) ; while ( start < end ) { if ( Str [ start ] == ' ▁ ' ) { start ++ ; continue ; } else if ( Str [ end ] == ' ▁ ' ) { end -- ; continue ; } else { char temp = Str [ start ] ; Str [ start ] = Str [ end ] ; Str [ end ] = temp ; start ++ ; end -- ; } } System . out . println ( String . valueOf ( Str ) ) ; } public static void main ( String [ ] args ) { String str = " internship ▁ at ▁ geeks ▁ for ▁ geeks " ; preserveSpace ( str ) ; } }

Index/key variables: end, start
Accumulator variables: end, start
Class/struct names: GFG
Java program:
import java . util . * ; import java . lang . * ; import java . io . * ; class AddSpaceinSentence { public static void amendSentence ( String sstr ) { char [ ] str = sstr . toCharArray ( ) ; for ( int i = 0 ; i < str . length ; i ++ ) { if ( str [ i ] >= ' A ' && str [ i ] <= ' Z ' ) { str [ i ] = ( char ) ( str [ i ] + 32 ) ; if ( i != 0 ) System . out . print ( " ▁ " ) ; System . out . print ( str [ i ] ) ; } else System . out . print ( str [ i ] ) ; } } public static void main ( String [ ] args ) { String str = " BruceWayneIsBatman " ; amendSentence ( str ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: AddSpaceinSentence
Java program:
class GFG { static String repeat ( String s , int n ) { String s1 = s ; for ( int i = 1 ; i < n ; i ++ ) s += s1 ; return s ; } public static void main ( String [ ] args ) { String s = " geeks " ; int n = 3 ; System . out . println ( repeat ( s , n ) ) ; } }

Accumulator variables: i, s
Iterator variables: i
Class/struct names: GFG
Java program:
public class GFG { static final int MAX_CHAR = 26 ; static int factorial ( int n ) { int fact = 1 ; for ( int i = 2 ; i <= n ; i ++ ) fact = fact * i ; return fact ; } static int countDistinctPermutations ( String str ) { int length = str . length ( ) ; int [ ] freq = new int [ MAX_CHAR ] ; for ( int i = 0 ; i < length ; i ++ ) if ( str . charAt ( i ) >= ' a ' ) freq [ str . charAt ( i ) - ' a ' ] ++ ; int fact = 1 ; for ( int i = 0 ; i < MAX_CHAR ; i ++ ) fact = fact * factorial ( freq [ i ] ) ; return factorial ( length ) / fact ; } public static void main ( String args [ ] ) { String str = " fvvfhvgv " ; System . out . println ( countDistinctPermutations ( str ) ) ; } }

Index/key variables: MAX_CHAR, i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GfG { boolean uniqueCharacters ( String str ) { int checker = 0 ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { int bitAtIndex = str . charAt ( i ) - ' a ' ; if ( ( checker & ( 1 << bitAtIndex ) ) > 0 ) return false ; checker = checker | ( 1 << bitAtIndex ) ; } return true ; } public static void main ( String args [ ] ) { GfG obj = new GfG ( ) ; String input = " geekforgeeks " ; if ( obj . uniqueCharacters ( input ) ) System . out . println ( " The ▁ String ▁ " + input + " ▁ has ▁ all ▁ unique ▁ characters " ) ; else System . out . println ( " The ▁ String ▁ " + input + " ▁ has ▁ duplicate ▁ characters " ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GfG
Java program:
import java . util . * ; class GFG { static boolean isVowel ( char ch ) { if ( ch == ' a ' ch == ' e ' ch == ' i ' ch == ' o ' ch == ' u ' ) return true ; return false ; } static String createAltStr ( String str1 , String str2 , int start , int l ) { String finalStr = " " ; for ( int i = 0 , j = start ; j < l ; i ++ , j ++ ) finalStr = ( finalStr + str1 . charAt ( i ) ) + str2 . charAt ( j ) ; return finalStr ; } static String findAltStr ( String str ) { int nv = 0 , nc = 0 ; String vstr = " " , cstr = " " ; int l = str . length ( ) ; for ( int i = 0 ; i < l ; i ++ ) { char ch = str . charAt ( i ) ; if ( isVowel ( ch ) ) { nv ++ ; vstr = vstr + ch ; } else { nc ++ ; cstr = cstr + ch ; } } if ( Math . abs ( nv - nc ) >= 2 ) return " no ▁ such ▁ string " ; if ( nv > nc ) return ( vstr . charAt ( 0 ) + createAltStr ( cstr , vstr , 1 , nv ) ) ; if ( nc > nv ) return ( cstr . charAt ( 0 ) + createAltStr ( vstr , cstr , 1 , nc ) ) ; if ( cstr . charAt ( 0 ) < vstr . charAt ( 0 ) ) return createAltStr ( cstr , vstr , 0 , nv ) ; return createAltStr ( vstr , cstr , 0 , nc ) ; } public static void main ( String args [ ] ) { String str = " geeks " ; System . out . println ( findAltStr ( str ) ) ; } }

Accumulator variables: i, j, nc, nv
Iterator variables: i
Class/struct names: GFG
Java program:
class Number { public static void isKthBitSet ( int n , int k ) { if ( ( n & ( 1 << ( k - 1 ) ) ) > 0 ) System . out . print ( " SET " ) ; else System . out . print ( " NOT ▁ SET " ) ; } public static void main ( String [ ] args ) { int n = 5 , k = 1 ; isKthBitSet ( n , k ) ; } }

Class/struct names: Number
Java program:
class GFG { public static void main ( String [ ] args ) { StringBuilder str = new StringBuilder ( " geeksforgeeks " ) ; str . reverse ( ) ; System . out . println ( str ) ; } }

Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static boolean isPalRec ( String str , int s , int e ) { if ( s == e ) return true ; if ( ( str . charAt ( s ) ) != ( str . charAt ( e ) ) ) return false ; if ( s < e + 1 ) return isPalRec ( str , s + 1 , e - 1 ) ; return true ; } static boolean isPalindrome ( String str ) { int n = str . length ( ) ; if ( n == 0 ) return true ; return isPalRec ( str , 0 , n - 1 ) ; } public static void main ( String args [ ] ) { String str = " geeg " ; if ( isPalindrome ( str ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } }

Class/struct names: GFG
Java program:
public class GFG { static final int MAX_CHAR = 26 ; static int countSubstringWithEqualEnds ( String s ) { int result = 0 ; int n = s . length ( ) ; int [ ] count = new int [ MAX_CHAR ] ; for ( int i = 0 ; i < n ; i ++ ) count [ s . charAt ( i ) - ' a ' ] ++ ; for ( int i = 0 ; i < MAX_CHAR ; i ++ ) result += ( count [ i ] * ( count [ i ] + 1 ) / 2 ) ; return result ; } public static void main ( String args [ ] ) { String s = " abcab " ; System . out . println ( countSubstringWithEqualEnds ( s ) ) ; } }

Index/key variables: MAX_CHAR, i
Accumulator variables: i, result
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static char maxRepeating ( String str ) { int n = str . length ( ) ; int count = 0 ; char res = str . charAt ( 0 ) ; int cur_count = 1 ; for ( int i = 0 ; i < n ; i ++ ) { if ( i < n - 1 && str . charAt ( i ) == str . charAt ( i + 1 ) ) cur_count ++ ; else { if ( cur_count > count ) { count = cur_count ; res = str . charAt ( i ) ; } cur_count = 1 ; } } return res ; } public static void main ( String args [ ] ) { String str = " aaaabbaaccde " ; System . out . println ( maxRepeating ( str ) ) ; } }

Accumulator variables: cur_count, i
Iterator variables: i
Class/struct names: GFG
Java program:
public class Query_Subsequence { static final int MAX = 10000 ; static final int CHAR_SIZE = 26 ; static void precompute ( int mat [ ] [ ] , String str , int len ) { for ( int i = 0 ; i < CHAR_SIZE ; ++ i ) mat [ len ] [ i ] = len ; for ( int i = len - 1 ; i >= 0 ; -- i ) { for ( int j = 0 ; j < CHAR_SIZE ; ++ j ) mat [ i ] [ j ] = mat [ i + 1 ] [ j ] ; mat [ i ] [ str . charAt ( i ) - ' a ' ] = i ; } } static boolean query ( int mat [ ] [ ] , String str , int len ) { int pos = 0 ; for ( int i = 0 ; i < str . length ( ) ; ++ i ) { if ( mat [ pos ] [ str . charAt ( i ) - ' a ' ] >= len ) return false ; else pos = mat [ pos ] [ str . charAt ( i ) - ' a ' ] + 1 ; } return true ; } public static void main ( String args [ ] ) { String S = " geeksforgeeks " ; int len = S . length ( ) ; int [ ] [ ] mat = new int [ MAX ] [ CHAR_SIZE ] ; precompute ( mat , S , len ) ; String get = query ( mat , " gg " , len ) ? " Yes " : " No " ; System . out . println ( get ) ; get = query ( mat , " gro " , len ) ? " Yes " : " No " ; System . out . println ( get ) ; get = query ( mat , " gfg " , len ) ? " Yes " : " No " ; System . out . println ( get ) ; get = query ( mat , " orf " , len ) ? " Yes " : " No " ; System . out . println ( get ) ; } }

Index/key variables: CHAR_SIZE, MAX, i, j, len, pos
Iterator variables: i, j
Class/struct names: Query_Subsequence
Java program:
import java . io . * ; public class GFG { static void query ( String s , int i , int j ) { int n = s . length ( ) ; i %= n ; j %= n ; if ( s . charAt ( i ) == s . charAt ( j ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } static public void main ( String [ ] args ) { String X = " geeksforgeeks " ; query ( X , 0 , 8 ) ; query ( X , 8 , 13 ) ; query ( X , 6 , 15 ) ; } }

Class/struct names: GFG
Java program:
class Test { static int countPairs ( String str ) { int result = 0 ; int n = str . length ( ) ; for ( int i = 0 ; i < n ; i ++ ) for ( int j = i + 1 ; j < n ; j ++ ) if ( Math . abs ( str . charAt ( i ) - str . charAt ( j ) ) == Math . abs ( i - j ) ) result ++ ; return result ; } public static void main ( String args [ ] ) { String str = " geeksforgeeks " ; System . out . println ( countPairs ( str ) ) ; } }

Accumulator variables: i, j, result
Iterator variables: i, j
Class/struct names: Test
Java program:
class GFG { static void longestString ( String str1 , String str2 ) { int count1 [ ] = new int [ 26 ] , count2 [ ] = new int [ 26 ] ; for ( int i = 0 ; i < str1 . length ( ) ; i ++ ) { count1 [ str1 . charAt ( i ) - ' a ' ] ++ ; } for ( int i = 0 ; i < str2 . length ( ) ; i ++ ) { count2 [ str2 . charAt ( i ) - ' a ' ] ++ ; } String result = " " ; { for ( int j = 1 ; j <= Math . min ( count1 [ i ] , count2 [ i ] ) ; j ++ ) { result += ( char ) ( ' a ' + i ) ; } } System . out . println ( result ) ; } public static void main ( String [ ] args ) { String str1 = " geeks " , str2 = " cake " ; longestString ( str1 , str2 ) ; } }

Index/key variables: i
Accumulator variables: i, j, result
Iterator variables: i, j
Class/struct names: GFG
Java program:
class GFG { static boolean checkPattern ( String str , String pattern ) { int len = pattern . length ( ) ; if ( str . length ( ) < len ) { return false ; } for ( int i = 0 ; i < len - 1 ; i ++ ) { char x = pattern . charAt ( i ) ; char y = pattern . charAt ( i + 1 ) ; int last = str . lastIndexOf ( x ) ; int first = str . indexOf ( y ) ; if ( last == - 1 first == - 1 last > first ) { return false ; } } return true ; } public static void main ( String [ ] args ) { String str = " engineers ▁ rock " ; String pattern = " gsr " ; System . out . println ( checkPattern ( str , pattern ) ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int findSum ( String str ) { String temp = "0" ; int sum = 0 ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { char ch = str . charAt ( i ) ; if ( Character . isDigit ( ch ) ) temp += ch ; else { sum += Integer . parseInt ( temp ) ; temp = "0" ; } } return sum + Integer . parseInt ( temp ) ; } public static void main ( String [ ] args ) { String str = "12abc20yz68" ; System . out . println ( findSum ( str ) ) ; } }

Accumulator variables: i, sum, temp
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . Arrays ; public class CountKSubStr { int countkDist ( String str , int k ) { int res = 0 ; int n = str . length ( ) ; int cnt [ ] = new int [ 26 ] ; for ( int i = 0 ; i < n ; i ++ ) { int dist_count = 0 ; Arrays . fill ( cnt , 0 ) ; for ( int j = i ; j < n ; j ++ ) { if ( cnt [ str . charAt ( j ) - ' a ' ] == 0 ) dist_count ++ ; cnt [ str . charAt ( j ) - ' a ' ] ++ ; if ( dist_count == k ) res ++ ; } } return res ; } public static void main ( String [ ] args ) { CountKSubStr ob = new CountKSubStr ( ) ; String ch = " abcbaa " ; int k = 3 ; System . out . println ( " Total ▁ substrings ▁ with ▁ exactly ▁ " + k + " ▁ distinct ▁ characters ▁ : ▁ " + ob . countkDist ( ch , k ) ) ; } }

Accumulator variables: dist_count, i, j, res
Iterator variables: i, j
Class/struct names: CountKSubStr
Java program:
class GFG { static String to_upper ( char [ ] in ) { for ( int i = 0 ; i < in . length ; i ++ ) { if ( ' a ' <= in [ i ] & in [ i ] <= ' z ' ) { in [ i ] = ( char ) ( in [ i ] - ' a ' + ' A ' ) ; } } return String . valueOf ( in ) ; } public static void main ( String [ ] args ) { String str = " geeksforgeeks " ; System . out . println ( to_upper ( str . toCharArray ( ) ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int findMinLength ( String arr [ ] , int n ) { int min = arr [ 0 ] . length ( ) ; for ( int i = 1 ; i < n ; i ++ ) { if ( arr [ i ] . length ( ) < min ) { min = arr [ i ] . length ( ) ; } } return ( min ) ; } static String commonPrefix ( String arr [ ] , int n ) { int minlen = findMinLength ( arr , n ) ; String result = " " ; for ( int i = 0 ; i < minlen ; i ++ ) { current = arr [ 0 ] . charAt ( i ) ; for ( int j = 1 ; j < n ; j ++ ) { if ( arr [ j ] . charAt ( i ) != current ) { return result ; } } result += ( current ) ; } return ( result ) ; } public static void main ( String [ ] args ) { String arr [ ] = { " geeksforgeeks " , " geeks " , " geek " , " geezer " } ; int n = arr . length ; String ans = commonPrefix ( arr , n ) ; if ( ans . length ( ) > 0 ) { System . out . println ( " The ▁ longest ▁ common ▁ prefix ▁ is ▁ " + ans ) ; } else { System . out . println ( " There ▁ is ▁ no ▁ common ▁ prefix " ) ; } } }

Index/key variables: i, j
Accumulator variables: i, j, result
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . Arrays ; class GFG { static void printZigZagConcat ( String str , int n ) { if ( n == 1 ) { System . out . print ( str ) ; return ; } char [ ] str1 = str . toCharArray ( ) ; int len = str . length ( ) ; String [ ] arr = new String [ n ] ; Arrays . fill ( arr , " " ) ; int row = 0 ; boolean down = true ; for ( int i = 0 ; i < len ; ++ i ) { arr [ row ] += ( str1 [ i ] ) ; if ( row == n - 1 ) { down = false ; } else if ( row == 0 ) { down = true ; } if ( down ) { row ++ ; } else { row -- ; } } for ( int i = 0 ; i < n ; ++ i ) { System . out . print ( arr [ i ] ) ; } } public static void main ( String [ ] args ) { String str = " GEEKSFORGEEKS " ; int n = 3 ; printZigZagConcat ( str , n ) ; } }

Index/key variables: i, n, row
Accumulator variables: row
Iterator variables: i
Boolean variables: down
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static boolean isPalin ( char [ ] str , int st , int end ) { while ( st < end ) { if ( str [ st ] != str [ end ] ) return false ; st ++ ; end -- ; } return true ; } static int findMinInsert ( char [ ] str , int n ) { for ( int i = n - 1 ; i >= 0 ; i -- ) { if ( isPalin ( str , 0 , i ) ) return ( n - i - 1 ) ; } return 0 ; } public static void main ( String [ ] args ) { char [ ] Input = " JAVA " . toCharArray ( ) ; System . out . println ( findMinInsert ( Input , Input . length ) ) ; } }

Index/key variables: end, st
Accumulator variables: end, i, st
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static long removeRecur ( long n ) { long prev_digit = n % 10 ; long pow = 10 ; long res = prev_digit ; while ( n > 0 ) { long curr_digit = n % 10 ; if ( curr_digit != prev_digit ) { res += curr_digit * pow ; prev_digit = curr_digit ; pow *= 10 ; } n = n / 10 ; } return res ; } public static void main ( String [ ] args ) { long n = 12224 ; System . out . println ( removeRecur ( n ) ) ; } }

Accumulator variables: pow, res
Class/struct names: GFG
Java program:
class GfG { static void stringFilter ( char str [ ] ) { int n = str . length ; int i = - 1 ; int j = 0 ; while ( j < n ) { if ( j < n - 1 && str [ j ] == ' a ' && str [ j + 1 ] == ' c ' ) j += 2 ; else if ( str [ j ] == ' b ' ) j ++ ; else if ( i >= 0 && str [ j ] == ' c ' && str [ i ] == ' a ' ) { i -- ; j ++ ; } else str [ ++ i ] = str [ j ++ ] ; } System . out . println ( new String ( str ) . substring ( 0 , i + 1 ) ) ; } public static void main ( String [ ] args ) { String str1 = " ad " ; stringFilter ( str1 . toCharArray ( ) ) ; String str2 = " acbac " ; stringFilter ( str2 . toCharArray ( ) ) ; String str3 = " aaac " ; stringFilter ( str3 . toCharArray ( ) ) ; String str4 = " react " ; stringFilter ( str4 . toCharArray ( ) ) ; String str5 = " aa " ; stringFilter ( str5 . toCharArray ( ) ) ; String str6 = " ababaac " ; stringFilter ( str6 . toCharArray ( ) ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Class/struct names: GfG
Java program:
class GFG { static int myAtoi ( char [ ] str ) { int sign = 1 , base = 0 , i = 0 ; while ( str [ i ] == ' ▁ ' ) { i ++ ; } if ( str [ i ] == ' - ' str [ i ] == ' + ' ) { sign = 1 - 2 * ( str [ i ++ ] == ' - ' ? 1 : 0 ) ; } while ( i < str . length && str [ i ] >= '0' && str [ i ] <= '9' ) { if ( base > Integer . MAX_VALUE / 10 || ( base == Integer . MAX_VALUE / 10 && str [ i ] - '0' > 7 ) ) { if ( sign == 1 ) return Integer . MAX_VALUE ; else return Integer . MIN_VALUE ; } base = 10 * base + ( str [ i ++ ] - '0' ) ; } return base * sign ; } public static void main ( String [ ] args ) { char str [ ] = " ▁ - 123" . toCharArray ( ) ; int val = myAtoi ( str ) ; System . out . printf ( " % d ▁ " , val ) ; } }

Index/key variables: i
Accumulator variables: i
Class/struct names: GFG