dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
class GFG { static int countSubstrs ( String str , int i , int j , int n ) { if ( n == 1 ) return 1 ; if ( n <= 0 ) return 0 ; int res = countSubstrs ( str , i + 1 , j , n - 1 ) + countSubstrs ( str , i , j - 1 , n - 1 ) - countSubstrs ( str , i + 1 , j - 1 , n - 2 ) ; if ( str . charAt ( i ) == str . charAt ( j ) ) res ++ ; return res ; } public static void main ( String [ ] args ) { String str = " abcab " ; int n = str . length ( ) ; System . out . print ( countSubstrs ( str , 0 , n - 1 , n ) ) ; } }

Accumulator variables: res
Class/struct names: GFG
Java program:
public class Similar_strings { static int countManipulations ( String s1 , String s2 ) { int count = 0 ; int char_count [ ] = new int [ 26 ] ; for ( int i = 0 ; i < s1 . length ( ) ; i ++ ) char_count [ s1 . charAt ( i ) - ' a ' ] ++ ; for ( int i = 0 ; i < s2 . length ( ) ; i ++ ) { char_count [ s2 . charAt ( i ) - ' a ' ] -- ; } for ( int i = 0 ; i < 26 ; ++ i ) { if ( char_count [ i ] != 0 ) { count += Math . abs ( char_count [ i ] ) ; } } return count / 2 ; } public static void main ( String [ ] args ) { String s1 = " ddcf " ; String s2 = " cedk " ; System . out . println ( countManipulations ( s1 , s2 ) ) ; } }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Class/struct names: Similar_strings
Java program:
import java . io . * ; public class GFG { static int MAX_CHAR = 26 ; static int leastCount ( String s1 , String s2 , int n ) { int [ ] count1 = new int [ MAX_CHAR ] ; int [ ] count2 = new int [ MAX_CHAR ] ; for ( int i = 0 ; i < n ; i ++ ) { count1 [ s1 . charAt ( i ) - ' a ' ] += 1 ; count2 [ s2 . charAt ( i ) - ' a ' ] += 1 ; } int res = 0 ; for ( int i = 0 ; i < MAX_CHAR ; i ++ ) { if ( count1 [ i ] != 0 ) { res += Math . abs ( count1 [ i ] - count2 [ i ] ) ; } } return res ; } static public void main ( String [ ] args ) { String s1 = " abc " ; String s2 = " cdd " ; int len = s1 . length ( ) ; int res = leastCount ( s1 , s2 , len ) ; System . out . println ( res ) ; } }

Index/key variables: MAX_CHAR, i
Accumulator variables: i, res
Iterator variables: i
Class/struct names: GFG
Java program:
public class First_Palin { static final int MAX_CHAR = 26 ; static char stringPalindrome ( String A , String B ) { int [ ] countA = new int [ MAX_CHAR ] ; int [ ] countB = new int [ MAX_CHAR ] ; int l1 = A . length ( ) ; int l2 = B . length ( ) ; for ( int i = 0 ; i < l1 ; i ++ ) countA [ A . charAt ( i ) - ' a ' ] ++ ; for ( int i = 0 ; i < l2 ; i ++ ) countB [ B . charAt ( i ) - ' a ' ] ++ ; for ( int i = 0 ; i < 26 ; i ++ ) if ( ( countA [ i ] > 1 && countB [ i ] == 0 ) ) return ' A ' ; return ' B ' ; } public static void main ( String args [ ] ) { String a = " abcdea " ; String b = " bcdesg " ; System . out . println ( stringPalindrome ( a , b ) ) ; } }

Index/key variables: MAX_CHAR, i
Accumulator variables: i
Iterator variables: i
Class/struct names: First_Palin
Java program:
public class Longest_common_substr { static void printLCSubStr ( String X , String Y , int m , int n ) { int [ ] [ ] LCSuff = new int [ m + 1 ] [ n + 1 ] ; int len = 0 ; int row = 0 , col = 0 ; for ( int i = 0 ; i <= m ; i ++ ) { for ( int j = 0 ; j <= n ; j ++ ) { if ( i == 0 j == 0 ) LCSuff [ i ] [ j ] = 0 ; else if ( X . charAt ( i - 1 ) == Y . charAt ( j - 1 ) ) { LCSuff [ i ] [ j ] = LCSuff [ i - 1 ] [ j - 1 ] + 1 ; if ( len < LCSuff [ i ] [ j ] ) { len = LCSuff [ i ] [ j ] ; row = i ; col = j ; } } else LCSuff [ i ] [ j ] = 0 ; } } if ( len == 0 ) { System . out . println ( " No ▁ Common ▁ Substring " ) ; return ; } String resultStr = " " ; while ( LCSuff [ row ] [ col ] != 0 ) { -- len ; row -- ; col -- ; } System . out . println ( resultStr ) ; } public static void main ( String args [ ] ) { String X = " OldSite : GeeksforGeeks . org " ; String Y = " NewSite : GeeksQuiz . com " ; int m = X . length ( ) ; int n = Y . length ( ) ; printLCSubStr ( X , Y , m , n ) ; } }

Index/key variables: col, i, j, row
Accumulator variables: col, i, j, row
Iterator variables: i, j
Class/struct names: Longest_common_substr
Java program:
import java . util . * ; class GFG { static String findFirstRepeated ( String s ) { String token [ ] = s . split ( " ▁ " ) ; HashMap < String , Integer > setOfWords = new HashMap < String , Integer > ( ) ; for ( int i = 0 ; i < token . length ; i ++ ) { if ( setOfWords . containsKey ( token [ i ] ) ) else setOfWords . put ( token [ i ] , 1 ) ; } for ( int i = 0 ; i < token . length ; i ++ ) { int count = setOfWords . get ( token [ i ] ) ; if ( count > 1 ) { return token [ i ] ; } } return " NoRepetition " ; } public static void main ( String args [ ] ) { String s = " Ravi ▁ had ▁ been ▁ saying ▁ that ▁ he ▁ had ▁ been ▁ there " ; String firstWord = findFirstRepeated ( s ) ; if ( ! firstWord . equals ( " NoRepetition " ) ) System . out . println ( " First ▁ repeated ▁ word ▁ : : ▁ " + firstWord ) ; else System . out . println ( " No ▁ Repetitionn " ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; public class GFG { static String findFirstRepeated ( String s ) { String token [ ] = s . split ( " ▁ " ) ; HashSet < String > set = new HashSet < String > ( ) ; for ( int i = 0 ; i < token . length ; i ++ ) { if ( set . contains ( token [ i ] ) ) { return token [ i ] ; } set . add ( token [ i ] ) ; } return " NoRepetition " ; } public static void main ( String args [ ] ) { String s = " Ravi ▁ had ▁ been ▁ saying ▁ that ▁ he ▁ had ▁ been ▁ there " ; String firstWord = findFirstRepeated ( s ) ; if ( ! firstWord . equals ( " NoRepetition " ) ) System . out . println ( " First ▁ repeated ▁ word ▁ : : ▁ " + firstWord ) ; else System . out . println ( " No ▁ Repetitionn " ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static void substringConversions ( String str , int k , int b ) { for ( int i = 0 ; i + k <= str . length ( ) ; i ++ ) { String sub = str . substring ( i , i + k ) ; int sum = 0 , counter = 0 ; for ( int j = sub . length ( ) - 1 ; j >= 0 ; j -- ) { sum = ( int ) ( sum + ( ( sub . charAt ( j ) - '0' ) * Math . pow ( b , counter ) ) ) ; counter ++ ; } System . out . print ( sum + " ▁ " ) ; } } public static void main ( String [ ] args ) { String str = "12212" ; int b = 3 , k = 3 ; substringConversions ( str , b , k ) ; } }

Accumulator variables: counter, i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; import java . lang . * ; import java . io . * ; class LongestPalindromicChunk { private static int LPCRec ( String curr_str , int count , int len , String str ) { if ( curr_str == null || curr_str . isEmpty ( ) ) return ( 0 ) ; if ( curr_str . length ( ) <= 1 ) { if ( count != 0 && str . length ( ) - len <= 1 ) return ( count + 1 ) ; else return ( 1 ) ; } int n = curr_str . length ( ) ; for ( int i = 0 ; i < n / 2 ; i ++ ) { if ( curr_str . substring ( 0 , i + 1 ) . equals ( curr_str . substring ( n - 1 - i , n ) ) ) { return LPCRec ( curr_str . substring ( i + 1 , n - 1 - i ) , count + 2 , len + ( i + 1 ) * 2 , str ) ; } } return count + 1 ; } public static int LPC ( String str ) { return LPCRec ( str , 0 , 0 , str ) ; } public static void main ( String [ ] args ) { System . out . println ( " V ▁ : ▁ " + LPC ( " V " ) ) ; System . out . println ( " VOLVO ▁ : ▁ " + LPC ( " VOLVO " ) ) ; System . out . println ( " VOLVOV ▁ : ▁ " + LPC ( " VOLVOV " ) ) ; System . out . println ( " ghiabcdefhelloadamhelloabcdefghi ▁ : ▁ " + LPC ( " ghiabcdefhelloadamhelloabcdefghi " ) ) ; System . out . println ( " ghiabcdefhelloadamhelloabcdefghik ▁ : ▁ " + LPC ( " ghiabcdefhelloadamhelloabcdefghik " ) ) ; System . out . println ( " antaprezatepzapreanta ▁ : ▁ " + LPC ( " antaprezatepzapreanta " ) ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: LongestPalindromicChunk
Java program:
class GFG { static final int MAX_CHAR = 256 ; static int countBalance ( String s ) { char [ ] str = s . toCharArray ( ) ; int [ ] rightVisited = new int [ MAX_CHAR ] ; int [ ] leftVisited = new int [ MAX_CHAR ] ; for ( int i = 0 ; i < n ; i ++ ) rightVisited [ str [ i ] ] ++ ; int res = 0 ; for ( int i = 0 ; i < n ; i ++ ) { leftVisited [ str [ i ] ] ++ ; rightVisited [ str [ i ] ] -- ; int j ; for ( j = 0 ; j < MAX_CHAR ; j ++ ) { if ( ( leftVisited [ j ] == 0 && rightVisited [ j ] != 0 ) || ( leftVisited [ j ] != 0 && rightVisited [ j ] == 0 ) ) break ; } if ( j == MAX_CHAR ) res ++ ; } return res ; } public static void main ( String [ ] args ) { String str = " abaababa " ; System . out . println ( countBalance ( str ) ) ; } }

Index/key variables: MAX_CHAR, i, j
Accumulator variables: i, j, res
Iterator variables: i, j
Class/struct names: GFG
Java program:
public class minFlips { static int findFlips ( String str , int n ) { char last = ' ▁ ' ; int res = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( last != str . charAt ( i ) ) res ++ ; last = str . charAt ( i ) ; } return res / 2 ; } public static void main ( String [ ] args ) { String str = "00011110001110" ; int n = str . length ( ) ; System . out . println ( findFlips ( str , n ) ) ; } }

Accumulator variables: i, res
Iterator variables: i
Class/struct names: minFlips
Java program:
public class GFG { static int findLen ( String A , int n , int k , char ch ) { int maxlen = 1 ; int cnt = 0 ; int l = 0 , r = 0 ; while ( r < n ) { if ( A . charAt ( r ) != ch ) ++ cnt ; while ( cnt > k ) { if ( A . charAt ( l ) != ch ) -- cnt ; ++ l ; } maxlen = Math . max ( maxlen , r - l + 1 ) ; ++ r ; } return maxlen ; } static int answer ( String A , int n , int k ) { int maxlen = 1 ; for ( int i = 0 ; i < 26 ; ++ i ) { maxlen = Math . max ( maxlen , findLen ( A , n , k , ( char ) ( i + ' A ' ) ) ) ; maxlen = Math . max ( maxlen , findLen ( A , n , k , ( char ) ( i + ' a ' ) ) ) ; } return maxlen ; } public static void main ( String [ ] args ) { int n = 5 , k = 2 ; String A = " ABABA " ; System . out . println ( " Maximum ▁ length ▁ = ▁ " + answer ( A , n , k ) ) ; n = 6 ; k = 4 ; String B = " HHHHHH " ; System . out . println ( " Maximum ▁ length ▁ = ▁ " + answer ( B , n , k ) ) ; } }

Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { public static void allCharactersSame ( String s ) { Set < Character > s1 = new HashSet < Character > ( ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) s1 . add ( s . charAt ( i ) ) ; if ( s1 . size ( ) == 1 ) System . out . println ( " YES " ) ; else System . out . println ( " NO " ) ; } public static void main ( String [ ] args ) { String str = " nnnn " ; allCharactersSame ( str ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
public class GFG { static void printMinIndexChar ( String str , String patt ) { int minIndex = Integer . MAX_VALUE ; int m = str . length ( ) ; int n = patt . length ( ) ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { if ( patt . charAt ( i ) == str . charAt ( j ) && j < minIndex ) { minIndex = j ; break ; } } } if ( minIndex != Integer . MAX_VALUE ) System . out . println ( " Minimum ▁ Index ▁ Character ▁ = ▁ " + str . charAt ( minIndex ) ) ; else System . out . println ( " No ▁ character ▁ present " ) ; } public static void main ( String [ ] args ) { String str = " geeksforgeeks " ; String patt = " set " ; printMinIndexChar ( str , patt ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . HashMap ; public class GFG { static void printMinIndexChar ( String str , String patt ) { HashMap < Character , Integer > hm = new HashMap < > ( ) ; int minIndex = Integer . MAX_VALUE ; int m = str . length ( ) ; int n = patt . length ( ) ; for ( int i = 0 ; i < m ; i ++ ) if ( ! hm . containsKey ( str . charAt ( i ) ) ) hm . put ( str . charAt ( i ) , i ) ; for ( int i = 0 ; i < n ; i ++ ) if ( hm . containsKey ( patt . charAt ( i ) ) && hm . get ( patt . charAt ( i ) ) < minIndex ) minIndex = hm . get ( patt . charAt ( i ) ) ; if ( minIndex != Integer . MAX_VALUE ) System . out . println ( " Minimum ▁ Index ▁ Character ▁ = ▁ " + str . charAt ( minIndex ) ) ; else System . out . println ( " No ▁ character ▁ present " ) ; } public static void main ( String [ ] args ) { String str = " geeksforgeeks " ; String patt = " set " ; printMinIndexChar ( str , patt ) ; } }

Accumulator variables: 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 [ ] count1 = new int [ MAX_CHAR ] ; int [ ] count2 = new int [ MAX_CHAR ] ; int n = s . length ( ) ; if ( n == 1 ) return true ; for ( int i = 0 , j = n - 1 ; i < j ; i ++ , j -- ) { count1 [ s . charAt ( i ) - ' a ' ] ++ ; count2 [ s . charAt ( j ) - ' a ' ] ++ ; } for ( int i = 0 ; i < MAX_CHAR ; i ++ ) if ( count1 [ i ] != count2 [ i ] ) 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 GFG { static int count9s ( char number [ ] ) { int n = number . length ; int d [ ] = new int [ 9 ] ; d [ 0 ] = 1 ; int result = 0 ; int mod_sum = 0 , continuous_zero = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( ( number [ i ] - '0' ) == 0 ) { continuous_zero ++ ; } else { continuous_zero = 0 ; } mod_sum += ( number [ i ] - '0' ) ; mod_sum %= 9 ; result += d [ mod_sum ] ; d [ mod_sum ] ++ ; result -= continuous_zero ; } return result ; } public static void main ( String [ ] args ) { System . out . println ( count9s ( "01809" . toCharArray ( ) ) ) ; System . out . println ( count9s ( "1809" . toCharArray ( ) ) ) ; System . out . println ( count9s ( "4189" . toCharArray ( ) ) ) ; } }

Index/key variables: i, mod_sum
Accumulator variables: continuous_zero, i, mod_sum, result
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static String maximumNum ( String curr_num , String res ) { int len1 = curr_num . length ( ) ; int len2 = res . length ( ) ; if ( len1 == len2 ) { int i = 0 ; while ( curr_num . charAt ( i ) == res . charAt ( i ) ) i ++ ; if ( curr_num . charAt ( i ) < res . charAt ( i ) ) return res ; else return curr_num ; } return len1 < len2 ? res : curr_num ; } static String extractMaximum ( String str ) { int n = str . length ( ) ; String curr_num = " " ; String res = " " ; for ( int i = 0 ; i < n ; i ++ ) { while ( i < n && str . charAt ( i ) == '0' ) i ++ ; while ( i < n && Character . isDigit ( str . charAt ( i ) ) ) { curr_num = curr_num + str . charAt ( i ) ; i ++ ; } if ( i == n ) break ; if ( curr_num . length ( ) > 0 ) i -- ; res = maximumNum ( curr_num , res ) ; curr_num = " " ; } if ( curr_num . length ( ) == 0 && res . length ( ) == 0 ) res = res + '0' ; return maximumNum ( curr_num , res ) ; } public static void main ( String [ ] args ) { String str = "100klh564abc365bg " ; System . out . println ( extractMaximum ( str ) ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class Test { static boolean isDivisible999 ( String num ) { int n = num . length ( ) ; if ( n == 0 && num . charAt ( 0 ) == '0' ) return true ; if ( n % 3 == 1 ) num = "00" + num ; if ( n % 3 == 2 ) num = "0" + num ; int gSum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int group = 0 ; group += ( num . charAt ( i ++ ) - '0' ) * 100 ; group += ( num . charAt ( i ++ ) - '0' ) * 10 ; group += num . charAt ( i ) - '0' ; gSum += group ; } if ( gSum > 1000 ) { num = Integer . toString ( gSum ) ; n = num . length ( ) ; gSum = isDivisible999 ( num ) ? 1 : 0 ; } return ( gSum == 999 ) ; } public static void main ( String args [ ] ) { String num = "1998" ; System . out . println ( isDivisible999 ( num ) ? " Divisible " : " Not ▁ divisible " ) ; } }

Accumulator variables: gSum, group, i
Iterator variables: i
Class/struct names: Test
Java program:
class Test { static final int MAX_CHAR = 26 ; static String arrangeString ( String str ) { int char_count [ ] = new int [ MAX_CHAR ] ; int sum = 0 ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { if ( Character . isUpperCase ( str . charAt ( i ) ) ) char_count [ str . charAt ( i ) - ' A ' ] ++ ; else sum = sum + ( str . charAt ( i ) - '0' ) ; } String res = " " ; for ( int i = 0 ; i < MAX_CHAR ; i ++ ) { char ch = ( char ) ( ' A ' + i ) ; while ( char_count [ i ] -- != 0 ) res = res + ch ; } if ( sum > 0 ) res = res + sum ; return res ; } public static void main ( String args [ ] ) { String str = " ACCBA10D2EW30" ; System . out . println ( arrangeString ( str ) ) ; } }

Index/key variables: MAX_CHAR, i
Accumulator variables: i
Iterator variables: i
Class/struct names: Test
Java program:
class GFG { public static void main ( String [ ] args ) { String str = " Mr ▁ John ▁ Smith ▁ " ; str = str . trim ( ) ; str = str . replaceAll ( " \\ s " , " % 20" ) ; System . out . println ( str ) ; } }

Class/struct names: GFG
Java program:
class GFG { static void subString ( char str [ ] , int n ) { for ( int len = 1 ; len <= n ; len ++ ) { for ( int i = 0 ; i <= n - len ; i ++ ) { int j = i + len - 1 ; for ( int k = i ; k <= j ; k ++ ) { System . out . print ( str [ k ] ) ; } System . out . println ( ) ; } } } public static void main ( String [ ] args ) { char str [ ] = { ' a ' , ' b ' , ' c ' } ; subString ( str , str . length ) ; } }

Index/key variables: k
Accumulator variables: i, k, len
Iterator variables: i, k, len
Class/struct names: GFG
Java program:
public class ReverseStringPreserveSpace { static void reverses ( String str ) { char [ ] inputArray = str . toCharArray ( ) ; char [ ] result = new char [ inputArray . length ] ; for ( int i = 0 ; i < inputArray . length ; i ++ ) { if ( inputArray [ i ] == ' ▁ ' ) { result [ i ] = ' ▁ ' ; } } int j = result . length - 1 ; for ( int i = 0 ; i < inputArray . length ; i ++ ) { if ( inputArray [ i ] != ' ▁ ' ) { if ( result [ j ] == ' ▁ ' ) { j -- ; } result [ j ] = inputArray [ i ] ; j -- ; } } System . out . println ( String . valueOf ( result ) ) ; } public static void main ( String [ ] args ) { reverses ( " internship ▁ at ▁ geeks ▁ for ▁ geeks " ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i
Class/struct names: ReverseStringPreserveSpace
Java program:
class GFG { static int MAX_CHAR = 26 ; static void findAndPrintUncommonChars ( String str1 , String str2 ) { int present [ ] = new int [ MAX_CHAR ] ; for ( int i = 0 ; i < MAX_CHAR ; i ++ ) { present [ i ] = 0 ; } int l1 = str1 . length ( ) ; int l2 = str2 . length ( ) ; for ( int i = 0 ; i < l1 ; i ++ ) { present [ str1 . charAt ( i ) - ' a ' ] = 1 ; } for ( int i = 0 ; i < l2 ; i ++ ) { if ( present [ str2 . charAt ( i ) - ' a ' ] == 1 || present [ str2 . charAt ( i ) - ' a ' ] == - 1 ) { present [ str2 . charAt ( i ) - ' a ' ] = - 1 ; } else { present [ str2 . charAt ( i ) - ' a ' ] = 2 ; } } for ( int i = 0 ; i < MAX_CHAR ; i ++ ) { if ( present [ i ] == 1 present [ i ] == 2 ) { System . out . print ( ( char ) ( i + ' a ' ) + " ▁ " ) ; } } } public static void main ( String [ ] args ) { String str1 = " characters " ; String str2 = " alphabets " ; findAndPrintUncommonChars ( str1 , str2 ) ; } }

Index/key variables: MAX_CHAR, i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
public class GFG { public int lengthOfLastWord ( final String a ) { int len = 0 ; String x = a . trim ( ) ; for ( int i = 0 ; i < x . length ( ) ; i ++ ) { if ( x . charAt ( i ) == ' ▁ ' ) len = 0 ; else len ++ ; } return len ; } public static void main ( String [ ] args ) { String input = " Geeks ▁ For ▁ Geeks ▁ " ; GFG gfg = new GFG ( ) ; System . out . println ( " The ▁ length ▁ of ▁ last ▁ word ▁ is ▁ " + gfg . lengthOfLastWord ( input ) ) ; } }

Accumulator variables: i, len
Iterator variables: i
Class/struct names: GFG
Java program:
public class GFG { static boolean isVowel ( char ch ) { ch = Character . toUpperCase ( ch ) ; return ( ch == ' A ' ch == ' E ' ch == ' I ' ch == ' O ' ch == ' U ' ) ; } static int countVowels ( String str ) { int count = 0 ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) ++ count ; return count ; } public static void main ( String args [ ] ) { String str = " abc ▁ de " ; System . out . println ( countVowels ( str ) ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
public class Test { static int x = 32 ; static String toggleCase ( char [ ] a ) { for ( int i = 0 ; i < a . length ; i ++ ) { a [ i ] ^= 32 ; } return new String ( a ) ; } public static void main ( String [ ] args ) { String str = " CheRrY " ; System . out . print ( " Toggle ▁ case : ▁ " ) ; str = toggleCase ( str . toCharArray ( ) ) ; System . out . println ( str ) ; System . out . print ( " Original ▁ string : ▁ " ) ; str = toggleCase ( str . toCharArray ( ) ) ; System . out . println ( str ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: Test
Java program:
import java . util . * ; class GFG { static boolean uniqueCharacters ( String str ) { HashSet < Character > char_set = new HashSet < > ( ) ; for ( int c = 0 ; c < str . length ( ) ; c ++ ) { char_set . add ( str . charAt ( c ) ) ; } if ( char_set . size ( ) == str . length ( ) ) { return true ; } else { return false ; } } public static void main ( String [ ] args ) { String str = " GeeksforGeeks " ; if ( uniqueCharacters ( str ) ) { System . out . print ( " The ▁ String ▁ " + str + " has all unique charactersNEW_LINE"); } else { System . out . print ( " The ▁ String ▁ " + str + " has duplicate charactersNEW_LINE"); } } }

Accumulator variables: c
Iterator variables: c
Class/struct names: GFG
Java program:
class GFG { static void concatenate ( char a [ ] , char b [ ] , char c [ ] , int n1 , int n2 ) { int i ; for ( i = 0 ; i < n1 ; i ++ ) { c [ i ] = a [ i ] ; } for ( int j = 0 ; j < n2 ; j ++ ) { c [ i ++ ] = b [ j ] ; } } public static void main ( String [ ] args ) { char a [ ] = " Hi ▁ This ▁ is ▁ geeksforgeeks . ▁ " . toCharArray ( ) ; int n1 = a . length ; char b [ ] = " You ▁ are ▁ welcome ▁ here . " . toCharArray ( ) ; int n2 = b . length ; char c [ ] = new char [ n1 + n2 ] ; concatenate ( a , b , c , n1 , n2 ) ; for ( int i = 0 ; i < n1 + n2 - 1 ; i ++ ) { System . out . print ( c [ i ] ) ; } } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static char [ ] S = " GeKf @ rGeek $ " . toCharArray ( ) ; static void toggleChars ( ) { for ( int i = 0 ; i < S . length ; i ++ ) { if ( Character . isAlphabetic ( S [ i ] ) ) { S [ i ] ^= ( 1 << 5 ) ; } } } public static void main ( String [ ] args ) { toggleChars ( ) ; System . out . print ( " String ▁ after ▁ toggle ▁ " + "NEW_LINE"); System . out . print ( String . valueOf ( S ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static String nextGreaterWithSameDigits ( char [ ] bnum ) { int l = bnum . length ; int i ; for ( i = l - 2 ; i >= 1 ; i -- ) { if ( bnum [ i ] == '0' && bnum [ i + 1 ] == '1' ) { char ch = bnum [ i ] ; bnum [ i ] = bnum [ i + 1 ] ; bnum [ i + 1 ] = ch ; break ; } } if ( i == 0 ) System . out . println ( " no ▁ greater ▁ number " ) ; int j = i + 2 , k = l - 1 ; while ( j < k ) { if ( bnum [ j ] == '1' && bnum [ k ] == '0' ) { char ch = bnum [ j ] ; bnum [ j ] = bnum [ k ] ; bnum [ k ] = ch ; j ++ ; k -- ; } else if ( bnum [ i ] == '0' ) break ; else j ++ ; } return String . valueOf ( bnum ) ; } public static void main ( String [ ] args ) { char [ ] bnum = "10010" . toCharArray ( ) ; System . out . println ( " Binary ▁ representation ▁ of ▁ next ▁ greater ▁ number ▁ = ▁ " + nextGreaterWithSameDigits ( bnum ) ) ; } }

Index/key variables: i, j, k
Accumulator variables: i, j, k
Iterator variables: i
Class/struct names: GFG