dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
import java . util . Arrays ; class GFG { static final int SIZE = 26 ; 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 char_freq [ ] = new int [ SIZE ] ; Arrays . fill ( char_freq , 0 ) ; 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 ++ ; } else { nc ++ ; } char_freq [ ch - 97 ] ++ ; } if ( Math . abs ( nv - nc ) >= 2 ) { return " no ▁ such ▁ String " ; } for ( int i = 0 ; i < SIZE ; i ++ ) { char ch = ( char ) ( i + 97 ) ; for ( int j = 1 ; j <= char_freq [ i ] ; j ++ ) { if ( isVowel ( ch ) ) { vstr += ch ; } else { cstr += ch ; } } } 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 = " aeroplane " ; System . out . println ( findAltStr ( str ) ) ; } }

Index/key variables: SIZE, i
Accumulator variables: cstr, i, j, nc, nv, vstr
Iterator variables: i, j
Class/struct names: GFG
Java program:
class GFG { static final int SIZE = 100 ; static String base64Decoder ( char encoded [ ] , int len_str ) { char [ ] decoded_String ; decoded_String = new char [ SIZE ] ; int i , j , k = 0 ; int num = 0 ; int count_bits = 0 ; for ( i = 0 ; i < len_str ; i += 4 ) { num = 0 ; count_bits = 0 ; for ( j = 0 ; j < 4 ; j ++ ) { if ( encoded [ i + j ] != ' = ' ) { num = num << 6 ; count_bits += 6 ; } if ( encoded [ i + j ] >= ' A ' && encoded [ i + j ] <= ' Z ' ) num = num | ( encoded [ i + j ] - ' A ' ) ; else if ( encoded [ i + j ] >= ' a ' && encoded [ i + j ] <= ' z ' ) num = num | ( encoded [ i + j ] - ' a ' + 26 ) ; else if ( encoded [ i + j ] >= '0' && encoded [ i + j ] <= '9' ) num = num | ( encoded [ i + j ] - '0' + 52 ) ; else if ( encoded [ i + j ] == ' + ' ) num = num | 62 ; else if ( encoded [ i + j ] == ' / ' ) num = num | 63 ; else { num = num >> 2 ; count_bits -= 2 ; } } while ( count_bits != 0 ) { count_bits -= 8 ; decoded_String [ k ++ ] = ( char ) ( ( num >> count_bits ) & 255 ) ; } } return String . valueOf ( decoded_String ) ; } public static void main ( String [ ] args ) { char encoded_String [ ] = " TUVOT04 = " . toCharArray ( ) ; int len_str = encoded_String . length ; len_str -= 1 ; System . out . printf ( "Encoded String : %sNEW_LINE", String . valueOf ( encoded_String ) ) ; System . out . printf ( "Decoded_String : %sNEW_LINE", base64Decoder ( encoded_String , len_str ) ) ; } }

Index/key variables: SIZE
Accumulator variables: count_bits, i, j, k, len_str
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void printSubsequences ( String s ) { char [ ] str = s . toCharArray ( ) ; int n = str . length ; int opsize = ( int ) ( Math . pow ( 2 , n - 1 ) ) ; for ( int counter = 0 ; counter < opsize ; counter ++ ) { for ( int j = 0 ; j < n ; j ++ ) { System . out . print ( str [ j ] ) ; if ( ( counter & ( 1 << j ) ) > 0 ) System . out . print ( " ▁ " ) ; } System . out . println ( ) ; } } public static void main ( String [ ] args ) { String str = " AB " ; printSubsequences ( str ) ; } }

Index/key variables: j
Accumulator variables: counter, j
Iterator variables: counter, j
Class/struct names: GFG
Java program:
public class PermuteString { final static int MAX_CHAR = 26 ; final static int MAX_FACT = 20 ; static long fact [ ] = new long [ MAX_FACT ] ; static void precomputeFactorirals ( ) { fact [ 0 ] = 1 ; for ( int i = 1 ; i < MAX_FACT ; i ++ ) fact [ i ] = fact [ i - 1 ] * i ; } static void nPermute ( String str , int n ) { precomputeFactorirals ( ) ; int len = str . length ( ) ; int freq [ ] = new int [ MAX_CHAR ] ; for ( int i = 0 ; i < len ; i ++ ) freq [ str . charAt ( i ) - ' a ' ] ++ ; String out = " " ; int sum = 10 ; int k = 0 ; while ( sum >= n ) { for ( int i = 0 ; i < MAX_CHAR ; i ++ ) { if ( freq [ i ] == 0 ) continue ; freq [ i ] -- ; sum = 0 ; int xsum = ( int ) fact [ len - 1 - k ] ; for ( int j = 0 ; j < MAX_CHAR ; j ++ ) xsum /= fact [ freq [ j ] ] ; sum += xsum ; if ( sum >= n ) { out += ( char ) ( i + ' a ' ) ; k ++ ; n -= ( sum - xsum ) ; break ; } if ( sum < n ) freq [ i ] ++ ; } } for ( int i = MAX_CHAR - 1 ; k < len && i >= 0 ; i -- ) if ( freq [ i ] != 0 ) { out += ( char ) ( i + ' a ' ) ; freq [ i ++ ] -- ; } System . out . println ( out ) ; } public static void main ( String [ ] args ) { int n = 2 ; String str = " geeksquiz " ; nPermute ( str , n ) ; } }

Index/key variables: MAX_CHAR, MAX_FACT, i, j
Accumulator variables: i, j, k, n, out, sum, xsum
Iterator variables: i, j
Class/struct names: PermuteString
Java program:
import java . util . * ; class GFG { static int countDeletions ( String s ) { int ans = 0 ; char [ ] str = s . toCharArray ( ) ; for ( int i = 0 ; i < str . length - 1 ; i ++ ) if ( str [ i ] == str [ i + 1 ] ) ans ++ ; return ans ; } public static void main ( String [ ] args ) { String str = " AAABBB " ; System . out . println ( countDeletions ( str ) ) ; } }

Index/key variables: i
Accumulator variables: ans, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . HashMap ; import java . util . Map ; public class GFG { static int countWords ( String str [ ] , int n ) { HashMap < String , Integer > m = new HashMap < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( m . containsKey ( str [ i ] ) ) { int get = m . get ( str [ i ] ) ; m . put ( str [ i ] , get + 1 ) ; } else { m . put ( str [ i ] , 1 ) ; } } int res = 0 ; for ( Map . Entry < String , Integer > it : m . entrySet ( ) ) { if ( it . getValue ( ) == 2 ) res ++ ; } return res ; } public static void main ( String args [ ] ) { String s [ ] = { " hate " , " love " , " peace " , " love " , " peace " , " hate " , " love " , " peace " , " love " , " peace " } ; int n = s . length ; System . out . println ( countWords ( s , n ) ) ; } }

Index/key variables: i
Accumulator variables: i, res
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static final int V = 4 ; static boolean colorGraph ( int G [ ] [ ] , int color [ ] , int pos , int c ) { if ( color [ pos ] != - 1 && color [ pos ] != c ) return false ; color [ pos ] = c ; boolean ans = true ; for ( int i = 0 ; i < V ; i ++ ) { if ( G [ pos ] [ i ] == 1 ) { if ( color [ i ] == - 1 ) ans &= colorGraph ( G , color , i , 1 - c ) ; if ( color [ i ] != - 1 && color [ i ] != 1 - c ) return false ; } if ( ! ans ) return false ; } return true ; } static boolean isBipartite ( int G [ ] [ ] ) { int [ ] color = new int [ V ] ; for ( int i = 0 ; i < V ; i ++ ) color [ i ] = - 1 ; int pos = 0 ; return colorGraph ( G , color , pos , 1 ) ; } public static void main ( String [ ] args ) { int G [ ] [ ] = { { 0 , 1 , 0 , 1 } , { 1 , 0 , 1 , 0 } , { 0 , 1 , 0 , 1 } , { 1 , 0 , 1 , 0 } } ; if ( isBipartite ( G ) ) System . out . print ( " Yes " ) ; else System . out . print ( " No " ) ; } }

Index/key variables: V, i, pos
Accumulator variables: ans, i
Iterator variables: i
Boolean variables: ans
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static String evenlength ( String n ) { String res = n ; for ( int j = n . length ( ) - 1 ; j >= 0 ; -- j ) res += n . charAt ( j ) ; return res ; } public static void main ( String [ ] args ) { String n = "10" ; System . out . println ( evenlength ( n ) ) ; } }

Accumulator variables: res
Iterator variables: j
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int countinString ( char ch , String s ) { if ( s . length ( ) == 0 ) return 0 ; int count = 0 ; if ( s . charAt ( 0 ) == ch ) count ++ ; count += countinString ( ch , s . substring ( 1 ) ) ; return count ; } public static void main ( String [ ] args ) { String str = " geeksforgeeks " ; char c = ' e ' ; System . out . println ( countinString ( c , str ) ) ; } }

Accumulator variables: count
Class/struct names: GFG
Java program:
import java . util . * ; class GfG { boolean uniqueCharacters ( String str ) { for ( int i = 0 ; i < str . length ( ) ; i ++ ) for ( int j = i + 1 ; j < str . length ( ) ; j ++ ) if ( str . charAt ( i ) == str . charAt ( j ) ) return false ; return true ; } public static void main ( String args [ ] ) { GfG obj = new GfG ( ) ; String input = " GeeksforGeeks " ; 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, j
Iterator variables: i, j
Class/struct names: GfG
Java program:
class GFG { public static boolean strcheck ( String s1 , String s2 ) { if ( s1 . compareTo ( s2 ) != 0 ) return false ; return true ; } public static boolean check ( String s ) { if ( s . length ( ) >= 10 ) return true ; for ( int i = 1 ; i < s . length ( ) ; i ++ ) { for ( int j = i + 1 ; j < s . length ( ) ; j ++ ) { for ( int k = j + 1 ; k < s . length ( ) ; k ++ ) { String s1 = " " , s2 = " " , s3 = " " , s4 = " " ; try { s1 = s . substring ( 0 , i ) ; s2 = s . substring ( i , j - i ) ; s3 = s . substring ( j , k - j ) ; s4 = s . substring ( k , s . length ( ) - k ) ; } catch ( StringIndexOutOfBoundsException e ) { } if ( strcheck ( s1 , s2 ) && strcheck ( s1 , s3 ) && strcheck ( s1 , s4 ) && strcheck ( s2 , s3 ) && strcheck ( s2 , s4 ) && strcheck ( s3 , s4 ) ) return true ; } } } return false ; } public static void main ( String [ ] args ) { String str = " aaabb " ; if ( check ( str ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } }

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

Index/key variables: i
Accumulator variables: i, i_n1, i_n2, j, s
Iterator variables: i, j
Class/struct names: GFG
Java program:
public class GFG { static int findIndex ( String str ) { int len = str . length ( ) ; int open [ ] = new int [ len + 1 ] ; int close [ ] = new int [ len + 1 ] ; int index = - 1 ; open [ 0 ] = 0 ; close [ len ] = 0 ; if ( str . charAt ( 0 ) == ' ( ' ) open [ 1 ] = 1 ; if ( str . charAt ( len - 1 ) == ' ) ' ) close [ len - 1 ] = 1 ; for ( int i = 1 ; i < len ; i ++ ) { if ( str . charAt ( i ) == ' ( ' ) open [ i + 1 ] = open [ i ] + 1 ; else open [ i + 1 ] = open [ i ] ; } for ( int i = len - 2 ; i >= 0 ; i -- ) { if ( str . charAt ( i ) == ' ) ' ) close [ i ] = close [ i + 1 ] + 1 ; else close [ i ] = close [ i + 1 ] ; } if ( open [ len ] == 0 ) return len ; if ( close [ 0 ] == 0 ) return 0 ; for ( int i = 0 ; i <= len ; i ++ ) if ( open [ i ] == close [ i ] ) index = i ; return index ; } public static void main ( String [ ] args ) { String str = " ( ( ) ) ) ( ( ) ( ) ( ) ) ) ) " ; System . out . println ( findIndex ( str ) ) ; } }

Index/key variables: i, len
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static String decimalToBinary ( double num , int k_prec ) { String binary = " " ; int Integral = ( int ) num ; double fractional = num - Integral ; while ( Integral > 0 ) { int rem = Integral % 2 ; binary += ( ( char ) ( rem + '0' ) ) ; Integral /= 2 ; } binary = reverse ( binary ) ; binary += ( ' . ' ) ; while ( k_prec -- > 0 ) { fractional *= 2 ; int fract_bit = ( int ) fractional ; if ( fract_bit == 1 ) { fractional -= fract_bit ; binary += ( char ) ( 1 + '0' ) ; } else { binary += ( char ) ( 0 + '0' ) ; } } return binary ; } static String reverse ( String input ) { char [ ] temparray = input . toCharArray ( ) ; int left , right = 0 ; right = temparray . length - 1 ; for ( left = 0 ; left < right ; left ++ , right -- ) { char temp = temparray [ left ] ; temparray [ left ] = temparray [ right ] ; temparray [ right ] = temp ; } return String . valueOf ( temparray ) ; } public static void main ( String [ ] args ) { double n = 4.47 ; int k = 3 ; System . out . println ( decimalToBinary ( n , k ) ) ; n = 6.986 ; k = 5 ; System . out . println ( decimalToBinary ( n , k ) ) ; } }

Index/key variables: left, right
Accumulator variables: Integral, binary, fractional, k_prec, left, right
Iterator variables: left
Class/struct names: GFG
Java program:
class GFG { static boolean isSmaller ( String str1 , String str2 ) { int n1 = str1 . length ( ) , n2 = str2 . length ( ) ; if ( n1 < n2 ) return true ; if ( n2 < n1 ) return false ; for ( int i = 0 ; i < n1 ; i ++ ) { if ( str1 . charAt ( i ) < str2 . charAt ( i ) ) return true ; else if ( str1 . charAt ( i ) > str2 . charAt ( i ) ) return false ; } return false ; } static String findDiff ( String str1 , String str2 ) { if ( isSmaller ( str1 , str2 ) ) { String t = str1 ; str1 = str2 ; str2 = t ; } String str = " " ; int n1 = str1 . length ( ) , n2 = str2 . length ( ) ; int diff = n1 - n2 ; int carry = 0 ; for ( int i = n2 - 1 ; i >= 0 ; i -- ) { int sub = ( ( ( int ) str1 . charAt ( i + diff ) - ( int ) '0' ) - ( ( int ) str2 . charAt ( i ) - ( int ) '0' ) - carry ) ; if ( sub < 0 ) { sub = sub + 10 ; carry = 1 ; } else carry = 0 ; str += String . valueOf ( sub ) ; } for ( int i = n1 - n2 - 1 ; i >= 0 ; i -- ) { if ( str1 . charAt ( i ) == '0' && carry > 0 ) { str += "9" ; continue ; } int sub = ( ( ( int ) str1 . charAt ( i ) - ( int ) '0' ) - carry ) ; str += String . valueOf ( sub ) ; carry = 0 ; } return new StringBuilder ( str ) . reverse ( ) . toString ( ) ; } public static void main ( String [ ] args ) { String str1 = "88" ; String str2 = "1079" ; System . out . println ( findDiff ( str1 , str2 ) ) ; } }

Accumulator variables: i, str
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . Arrays ; class GFG { static boolean unique ( String s ) { Arrays . sort ( s . toCharArray ( ) ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == s . charAt ( i + 1 ) ) { return false ; } } return true ; } public static void main ( String [ ] args ) { if ( unique ( " abcdd " ) == true ) { System . out . println ( " String ▁ is ▁ Unique " ) ; } else { System . out . println ( " String ▁ is ▁ not ▁ Unique " ) ; } } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
public class GFG { static final int MAX_CHAR = 26 ; static boolean areKAnagrams ( String str1 , String str2 , int k ) { int n = str1 . length ( ) ; if ( str2 . length ( ) != n ) return false ; int [ ] hash_str1 = new int [ MAX_CHAR ] ; for ( int i = 0 ; i < n ; i ++ ) hash_str1 [ str1 . charAt ( i ) - ' a ' ] ++ ; int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( hash_str1 [ str2 . charAt ( i ) - ' a ' ] > 0 ) hash_str1 [ str2 . charAt ( i ) - ' a ' ] -- ; else count ++ ; if ( count > k ) return false ; } return true ; } public static void main ( String args [ ] ) { String str1 = " fodr " ; String str2 = " gork " ; int k = 2 ; if ( areKAnagrams ( str1 , str2 , k ) == true ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } }

Index/key variables: MAX_CHAR
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static char getDigit ( int N , int d ) { String str = Integer . toString ( N ) ; return str . charAt ( d - 1 ) ; } static char getNthChar ( int N ) { int sum = 0 , nine = 9 ; int dist = 0 , len ; for ( len = 1 ; ; len ++ ) { sum += nine * len ; dist += nine ; if ( sum >= N ) { sum -= nine * len ; dist -= nine ; N -= sum ; break ; } nine *= 10 ; } int diff = ( int ) ( Math . ceil ( ( double ) ( N ) / ( double ) ( len ) ) ) ; int d = N % len ; if ( d == 0 ) d = len ; return getDigit ( dist + diff , d ) ; } public static void main ( String [ ] args ) { int N = 251 ; System . out . println ( getNthChar ( N ) ) ; } }

Accumulator variables: N, dist, len, nine, sum
Iterator variables: len
Class/struct names: GFG
Java program:
class GFG { static boolean ispalindrome ( String s ) { int l = s . length ( ) ; for ( int i = 0 , j = l - 1 ; i <= j ; i ++ , j -- ) { if ( s . charAt ( i ) != s . charAt ( j ) ) { return false ; } } return true ; } public static void main ( String [ ] args ) { String s = " BABABAA " ; int cnt = 0 ; int flag = 0 ; while ( s . length ( ) > 0 ) { if ( ispalindrome ( s ) ) { flag = 1 ; break ; } else { cnt ++ ; s = s . substring ( 0 , s . length ( ) - 1 ) ; s . erase ( s . begin ( ) + s . length ( ) - 1 ) ; } } if ( flag == 1 ) { System . out . println ( cnt ) ; } } }

Accumulator variables: cnt, i, j
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int findCount ( String str ) { int result = 0 ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { if ( i == ( str . charAt ( i ) - ' a ' ) || i == ( str . charAt ( i ) - ' A ' ) ) { result ++ ; } } return result ; } public static void main ( String [ ] args ) { String str = " AbgdeF " ; System . out . print ( findCount ( str ) ) ; } }

Accumulator variables: i, result
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static boolean isPalindrome ( String str , int low , int high ) { while ( low < high ) { if ( str . charAt ( low ) != str . charAt ( high ) ) return false ; low ++ ; high -- ; } return true ; } static int possiblePalinByRemovingOneChar ( String str ) { int low = 0 , high = str . length ( ) - 1 ; while ( low < high ) { if ( str . charAt ( low ) == str . charAt ( high ) ) { low ++ ; high -- ; } else { if ( isPalindrome ( str , low + 1 , high ) ) return low ; if ( isPalindrome ( str , low , high - 1 ) ) return high ; return - 1 ; } } return - 2 ; } public static void main ( String [ ] args ) { String str = " abecbea " ; int idx = possiblePalinByRemovingOneChar ( str ) ; if ( idx == - 1 ) System . out . println ( " Not ▁ Possible " ) ; else if ( idx == - 2 ) System . out . println ( " Possible ▁ without ▁ " + " removing ▁ any ▁ character " ) ; else System . out . println ( " Possible ▁ by ▁ removing " + " ▁ character ▁ at ▁ index ▁ " + idx ) ; } }

Accumulator variables: high, low
Class/struct names: GFG
Java program:
import java . util . ArrayList ; import java . util . Arrays ; import java . util . List ; public class CamelCase { static final int ALPHABET_SIZE = 26 ; static class TrieNode { TrieNode [ ] children = new TrieNode [ ALPHABET_SIZE ] ; boolean isLeaf ; List < String > word ; public TrieNode ( ) { isLeaf = false ; for ( int i = 0 ; i < ALPHABET_SIZE ; i ++ ) children [ i ] = null ; word = new ArrayList < String > ( ) ; } } static TrieNode root ; static void insert ( String word ) { int index ; TrieNode pCrawl = root ; for ( int level = 0 ; level < word . length ( ) ; level ++ ) { if ( Character . isLowerCase ( word . charAt ( level ) ) ) continue ; index = word . charAt ( level ) - ' A ' ; if ( pCrawl . children [ index ] == null ) pCrawl . children [ index ] = new TrieNode ( ) ; pCrawl = pCrawl . children [ index ] ; } pCrawl . isLeaf = true ; ( pCrawl . word ) . add ( word ) ; } static void printAllWords ( TrieNode root ) { if ( root . isLeaf ) { for ( String str : root . word ) System . out . println ( str ) ; } for ( int i = 0 ; i < ALPHABET_SIZE ; i ++ ) { TrieNode child = root . children [ i ] ; if ( child != null ) printAllWords ( child ) ; } } static boolean search ( String pattern ) { int index ; TrieNode pCrawl = root ; for ( int level = 0 ; level < pattern . length ( ) ; level ++ ) { index = pattern . charAt ( level ) - ' A ' ; if ( pCrawl . children [ index ] == null ) return false ; pCrawl = pCrawl . children [ index ] ; } printAllWords ( pCrawl ) ; return true ; } static void findAllWords ( List < String > dict , String pattern ) { root = new TrieNode ( ) ; for ( String word : dict ) insert ( word ) ; if ( ! search ( pattern ) ) System . out . println ( " No ▁ match ▁ found " ) ; } public static void main ( String args [ ] ) { List < String > dict = Arrays . asList ( " Hi " , " Hello " , " HelloWorld " , " HiTech " , " HiGeek " , " HiTechWorld " , " HiTechCity " , " HiTechLab " ) ; String pattern = " HT " ; findAllWords ( dict , pattern ) ; } }

Index/key variables: ALPHABET_SIZE, i, index
Accumulator variables: i, level
Iterator variables: i, level, str, word
Boolean variables: isLeaf
Class/struct names: CamelCase, TrieNode
Java program:
import java . util . * ; import java . lang . * ; import java . io . * ; class binStr { public static void print ( char str [ ] , int index ) { if ( index == str . length ) { System . out . println ( str ) ; return ; } if ( str [ index ] == ' ? ' ) { str [ index ] = '0' ; print ( str , index + 1 ) ; str [ index ] = '1' ; print ( str , index + 1 ) ; str [ index ] = ' ? ' ; } else print ( str , index + 1 ) ; } public static void main ( String [ ] args ) { String input = "1 ? ? 0?101" ; char [ ] str = input . toCharArray ( ) ; print ( str , 0 ) ; } }

Index/key variables: index
Class/struct names: binStr
Java program:
import java . io . * ; class GFG { static int countOccurrences ( int x , int d ) { int count = 0 ; while ( x > 0 ) { if ( x % 10 == d ) count ++ ; x = x / 10 ; } return count ; } static int maxOccurring ( int x ) { if ( x < 0 ) x = - x ; int result = 0 ; int max_count = 1 ; for ( int d = 0 ; d <= 9 ; d ++ ) { int count = countOccurrences ( x , d ) ; if ( count >= max_count ) { max_count = count ; result = d ; } } return result ; } public static void main ( String [ ] args ) { int x = 1223355 ; System . out . println ( " Max ▁ occurring ▁ digit ▁ is ▁ " + maxOccurring ( x ) ) ; } }

Accumulator variables: count, d
Iterator variables: d
Class/struct names: GFG
Java program:
class GFG { static String removeRecurringDigits ( char num [ ] ) { int len = num . length ; String s = " " ; for ( int i = 0 ; i < len ; i ++ ) { s += String . valueOf ( num [ i ] ) ; while ( i + 1 < len && num [ i ] == num [ i + 1 ] ) { i ++ ; } } return s ; } public static void main ( String [ ] args ) { char num [ ] = "1299888833" . toCharArray ( ) ; System . out . print ( " Modified ▁ number ▁ is ▁ " + removeRecurringDigits ( num ) ) ; } }

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