dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
import java . util . * ; class GFG { static class node { char data ; int cnt ; node left , right ; } ; static node add ( char data ) { node newnode = new node ( ) ; newnode . data = data ; newnode . cnt = 1 ; newnode . left = newnode . right = null ; return newnode ; } static node addinlvlorder ( node root , char data ) { if ( root == null ) { return add ( data ) ; } Queue < node > Q = new LinkedList < node > ( ) ; Q . add ( root ) ; while ( ! Q . isEmpty ( ) ) { node temp = Q . peek ( ) ; Q . remove ( ) ; if ( temp . data == data ) { temp . cnt ++ ; break ; } if ( temp . left == null ) { temp . left = add ( data ) ; break ; } else { if ( temp . left . data == data ) { temp . left . cnt ++ ; break ; } Q . add ( temp . left ) ; } if ( temp . right == null ) { temp . right = add ( data ) ; break ; } else { if ( temp . right . data == data ) { temp . right . cnt ++ ; break ; } Q . add ( temp . right ) ; } } return root ; } static void printlvlorder ( node root ) { Queue < node > Q = new LinkedList < node > ( ) ; Q . add ( root ) ; while ( ! Q . isEmpty ( ) ) { node temp = Q . peek ( ) ; if ( temp . cnt > 1 ) { System . out . print ( ( temp . data + " " + temp . cnt ) ) ; } else { System . out . print ( ( char ) temp . data ) ; } Q . remove ( ) ; if ( temp . left != null ) { Q . add ( temp . left ) ; } if ( temp . right != null ) { Q . add ( temp . right ) ; } } } public static void main ( String [ ] args ) { String s = " geeksforgeeks " ; node root = null ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { root = addinlvlorder ( root , s . charAt ( i ) ) ; } printlvlorder ( root ) ; } }

Accumulator variables: cnt, i
Iterator variables: i
Class/struct names: GFG, node
Java program:
class GFG { static String replaceRemove ( char [ ] s , char X , char Y , char Z ) { int start = 0 , end = s . length - 1 ; while ( start <= end ) { if ( s [ start ] == Z ) { while ( end >= 0 && s [ end ] == Z ) { end -- ; } char temp ; if ( end > start ) { temp = s [ start ] ; s [ start ] = s [ end ] ; s [ end ] = temp ; if ( s [ start ] == X ) s [ start ] = Y ; start ++ ; } } else { if ( s [ start ] == X ) s [ start ] = Y ; start ++ ; } } String new_s = new String ( s ) ; while ( new_s . length ( ) > 0 && new_s . charAt ( new_s . length ( ) - 1 ) == Z ) { new_s = new_s . substring ( 0 , new_s . length ( ) - 1 ) ; } return new_s ; } public static void main ( String [ ] args ) { String str = " batman " ; char X = ' a ' , Y = ' d ' , Z = ' b ' ; str = replaceRemove ( str . toCharArray ( ) , X , Y , Z ) ; if ( str . length ( ) == 0 ) { System . out . println ( - 1 ) ; } else { System . out . println ( str ) ; } } }

Index/key variables: end, start
Accumulator variables: end, start
Class/struct names: GFG
Java program:
class GFG { static String canMake ( String s ) { int o = 0 , z = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) - '0' == 1 ) o ++ ; else z ++ ; } if ( o % 2 == 1 && z % 2 == 1 ) return " NO " ; else return " YES " ; } public static void main ( String [ ] args ) { String s = "01011" ; System . out . println ( canMake ( s ) ) ; } }

Accumulator variables: i, o, z
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { public static int count = 0 ; public static void countNumberOfStringsUtil ( int [ ] freq ) { for ( int i = 0 ; i < 26 ; i ++ ) { if ( freq [ i ] > 0 ) { freq [ i ] -- ; count ++ ; countNumberOfStringsUtil ( freq ) ; } } } public static int countNumberOfStrings ( String s ) { int [ ] freq = new int [ 26 ] ; Arrays . fill ( freq , 0 ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { freq [ s . charAt ( i ) - ' A ' ] ++ ; } countNumberOfStringsUtil ( freq ) ; return count ; } public static void main ( String [ ] args ) { String s = " AAABBC " ; System . out . println ( countNumberOfStrings ( s ) ) ; } }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int findMinSwaps ( String s , int k ) { int ans = 0 ; int c_one = 0 , c_zero = 0 ; for ( int i = s . length ( ) - 1 ; i >= 0 ; i -- ) { if ( s . charAt ( i ) == '1' ) c_one ++ ; if ( s . charAt ( i ) == '0' ) { c_zero ++ ; ans += c_one ; } if ( c_zero == k ) break ; } if ( c_zero < k ) return - 1 ; return ans ; } public static void main ( String [ ] args ) { String s = "100111" ; int k = 2 ; System . out . println ( findMinSwaps ( s , k ) ) ; } }

Accumulator variables: ans, c_one, c_zero, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static class Node { char data ; Node left , right ; Node ( char _val ) { data = _val ; left = right = null ; } } ; static Node addinBT ( Node root , char data ) { if ( root == null ) { root = new Node ( data ) ; } else { Queue < Node > Q = new LinkedList < Node > ( ) ; Q . add ( root ) ; while ( ! Q . isEmpty ( ) ) { Node temp = Q . peek ( ) ; Q . remove ( ) ; if ( temp . left == null ) { temp . left = new Node ( data ) ; break ; } else Q . add ( temp . left ) ; if ( temp . right == null ) { temp . right = new Node ( data ) ; break ; } else Q . add ( temp . right ) ; } } return root ; } static void print ( Node root ) { Queue < Node > Q = new LinkedList < Node > ( ) ; Q . add ( root ) ; while ( Q . size ( ) > 0 ) { Node temp = Q . peek ( ) ; Q . remove ( ) ; System . out . print ( temp . data ) ; if ( temp . left != null ) Q . add ( temp . left ) ; if ( temp . right != null ) Q . add ( temp . right ) ; } } static boolean checkvowel ( char ch ) { ch = Character . toLowerCase ( ch ) ; if ( ch == ' a ' ch == ' e ' ch == ' i ' ch == ' o ' ch == ' u ' ) { return true ; } else { return false ; } } static Node removevowels ( Node root ) { Queue < Node > Q = new LinkedList < Node > ( ) ; Q . add ( root ) ; Node root1 = null ; while ( ! Q . isEmpty ( ) ) { Node temp = Q . peek ( ) ; Q . remove ( ) ; if ( ! checkvowel ( temp . data ) ) { root1 = addinBT ( root1 , temp . data ) ; } if ( temp . left != null ) { Q . add ( temp . left ) ; } if ( temp . right != null ) { Q . add ( temp . right ) ; } } return root1 ; } public static void main ( String [ ] args ) { String s = " geeks " ; Node root = null ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { root = addinBT ( root , s . charAt ( i ) ) ; } root = removevowels ( root ) ; print ( root ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG, Node
Java program:
class GFG { static int countSubStr ( String str , int len ) { int ans = 0 ; for ( int i = 0 ; i < len ; i ++ ) { if ( str . charAt ( i ) == '0' ) ans += ( i + 1 ) ; } return ans ; } public static void main ( String [ ] args ) { String str = "10010" ; int len = str . length ( ) ; System . out . println ( countSubStr ( str , len ) ) ; } }

Accumulator variables: ans, i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static final int INT_MAX = Integer . MAX_VALUE ; static int findLength ( String s , int k ) { int ans = INT_MAX ; int l = 0 ; int r = 0 ; int cnt_zero = 0 , cnt_one = 0 ; while ( l < s . length ( ) && r <= s . length ( ) ) { if ( cnt_zero >= k && cnt_one >= 1 ) { ans = Math . min ( ans , r - l ) ; l ++ ; if ( s . charAt ( l - 1 ) == '0' ) cnt_zero -- ; else cnt_one -- ; } else { if ( r == s . length ( ) ) break ; if ( s . charAt ( r ) == '0' ) cnt_zero ++ ; else cnt_one ++ ; r ++ ; } } if ( ans == INT_MAX ) return - 1 ; return ans ; } public static void main ( String [ ] args ) { String s = "100" ; int k = 2 ; System . out . println ( findLength ( s , k ) ) ; } }

Accumulator variables: cnt_one, cnt_zero, l, r
Class/struct names: GFG
Java program:
class GFG { static String largestSubStr ( String s ) { while ( s . length ( ) != 0 && s . charAt ( s . length ( ) - 1 ) == '1' ) s = s . substring ( 0 , s . length ( ) - 1 ) ; if ( s . length ( ) == 0 ) return " - 1" ; else return s ; } public static void main ( String [ ] args ) { String s = "11001" ; System . out . println ( largestSubStr ( s ) ) ; } }

Class/struct names: GFG
Java program:
class GFG { static int MAX = 26 ; static boolean areEqual ( int [ ] a , int [ ] b ) { for ( int i = 0 ; i < MAX ; i ++ ) if ( a [ i ] != b [ i ] ) return false ; return true ; } static boolean xExistsInY ( String x , String y ) { if ( x . length ( ) > y . length ( ) ) return false ; int [ ] cnt_x = new int [ MAX ] ; int [ ] cnt = new int [ MAX ] ; for ( int i = 0 ; i < x . length ( ) ; i ++ ) cnt_x [ x . charAt ( i ) - ' a ' ] ++ ; for ( int i = 0 ; i < x . length ( ) ; i ++ ) cnt [ y . charAt ( i ) - ' a ' ] ++ ; if ( areEqual ( cnt_x , cnt ) ) return true ; for ( int i = 1 ; i < y . length ( ) - x . length ( ) + 1 ; i ++ ) { cnt [ y . charAt ( i - 1 ) - ' a ' ] -- ; cnt [ y . charAt ( i + x . length ( ) - 1 ) - ' a ' ] ++ ; if ( areEqual ( cnt , cnt_x ) ) return true ; } return false ; } public static void main ( String [ ] args ) { String x = " skege " ; String y = " geeksforgeeks " ; if ( xExistsInY ( x , y ) ) System . out . print ( " Yes " ) ; else System . out . print ( " No " ) ; } }

Index/key variables: MAX, i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { static void reverse ( char A [ ] , int l , int h ) { if ( l < h ) { char ch = A [ l ] ; A [ l ] = A [ h ] ; A [ h ] = ch ; reverse ( A , l + 1 , h - 1 ) ; } } static String reverseParentheses ( String str , int len ) { Stack < Integer > st = new Stack < Integer > ( ) ; for ( int i = 0 ; i < len ; i ++ ) { if ( str . charAt ( i ) == ' ( ' ) { st . push ( i ) ; } else if ( str . charAt ( i ) == ' ) ' ) { char [ ] A = str . toCharArray ( ) ; reverse ( A , st . peek ( ) + 1 , i ) ; str = String . copyValueOf ( A ) ; st . pop ( ) ; } } String res = " " ; for ( int i = 0 ; i < len ; i ++ ) { if ( str . charAt ( i ) != ' ) ' && str . charAt ( i ) != ' ( ' ) { res += ( str . charAt ( i ) ) ; } } return res ; } public static void main ( String [ ] args ) { String str = " ( skeeg ( for ) skeeg ) " ; int len = str . length ( ) ; System . out . println ( reverseParentheses ( str , len ) ) ; } }

Index/key variables: h, l
Accumulator variables: i, res
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int MAX = 26 ; static void updateFreq ( String str , int freq [ ] ) { int len = str . length ( ) ; for ( int i = 0 ; i < len ; i ++ ) { freq [ str . charAt ( i ) - ' a ' ] ++ ; } } static int maxCount ( String str , String patt ) { int [ ] strFreq = new int [ MAX ] ; updateFreq ( str , strFreq ) ; int [ ] pattFreq = new int [ MAX ] ; updateFreq ( patt , pattFreq ) ; int ans = Integer . MAX_VALUE ; for ( int i = 0 ; i < MAX ; i ++ ) { if ( pattFreq [ i ] == 0 ) continue ; ans = Math . min ( ans , strFreq [ i ] / pattFreq [ i ] ) ; } return ans ; } public static void main ( String [ ] args ) { String str = " geeksforgeeks " ; String patt = " geeks " ; System . out . print ( maxCount ( str , patt ) ) ; } }

Index/key variables: MAX, i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int TEN = 10 ; static int minNum ( char [ ] str , int len ) { int res = Integer . MAX_VALUE ; for ( int i = 0 ; i < len ; i ++ ) { if ( str [ i ] == '4' str [ i ] == '8' ) { res = Math . min ( res , str [ i ] - '0' ) ; } } for ( int i = 0 ; i < len - 1 ; i ++ ) { for ( int j = i + 1 ; j < len ; j ++ ) { int num = ( str [ i ] - '0' ) * TEN + ( str [ j ] - '0' ) ; if ( num % 4 == 0 ) { res = Math . min ( res , num ) ; } } } return ( ( res == Integer . MAX_VALUE ) ? - 1 : res ) ; } public static void main ( String [ ] args ) { String str = "17" ; int len = str . length ( ) ; System . out . print ( minNum ( str . toCharArray ( ) , len ) ) ; } }

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 boolean canBeEqual ( char [ ] a , char [ ] b , int n ) { Vector < Character > A = new Vector < > ( ) ; Vector < Character > B = new Vector < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] != b [ i ] ) { A . add ( a [ i ] ) ; B . add ( b [ i ] ) ; } } if ( A . size ( ) == B . size ( ) && B . size ( ) == 0 ) return true ; if ( A . size ( ) == B . size ( ) && B . size ( ) == 2 ) { if ( A . get ( 0 ) == A . get ( 1 ) && B . get ( 0 ) == B . get ( 1 ) ) return true ; } return false ; } public static void main ( String [ ] args ) { char [ ] A = " SEEKSFORGEEKS " . toCharArray ( ) ; char [ ] B = " GEEKSFORGEEKG " . toCharArray ( ) ; if ( canBeEqual ( A , B , A . length ) ) System . out . printf ( " Yes " ) ; else System . out . printf ( " No " ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static void findMidAlphabet ( String s1 , String s2 , int n ) { for ( int i = 0 ; i < n ; i ++ ) { int mid = ( s1 . charAt ( i ) + s2 . charAt ( i ) ) / 2 ; System . out . print ( ( char ) mid ) ; } } public static void main ( String [ ] args ) { String s1 = " akzbqzgw " ; String s2 = " efhctcsz " ; int n = s1 . length ( ) ; findMidAlphabet ( s1 , s2 , n ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static final int N = 2 ; static Boolean isVowel ( char ch ) { return ( ch == ' a ' ch == ' e ' ch == ' i ' ch == ' o ' ch == ' u ' ) ; } static void performQueries ( String str , int len , int queries [ ] [ ] , int q ) { int [ ] pre = new int [ len ] ; if ( isVowel ( str . charAt ( 0 ) ) ) pre [ 0 ] = 1 ; else pre [ 0 ] = 0 ; for ( int i = 1 ; i < len ; i ++ ) { if ( isVowel ( str . charAt ( i ) ) ) pre [ i ] = 1 + pre [ i - 1 ] ; else pre [ i ] = pre [ i - 1 ] ; } for ( int i = 0 ; i < q ; i ++ ) { if ( queries [ i ] [ 0 ] == 0 ) { System . out . println ( pre [ queries [ i ] [ 1 ] ] ) ; } else { System . out . println ( ( pre [ queries [ i ] [ 1 ] ] - pre [ queries [ i ] [ 0 ] - 1 ] ) ) ; } } } public static void main ( String [ ] args ) { String str = " geeksforgeeks " ; int len = str . length ( ) ; int queries [ ] [ ] = { { 1 , 3 } , { 2 , 4 } , { 1 , 9 } } ; int q = queries . length ; performQueries ( str , len , queries , q ) ; } }

Index/key variables: i, len
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int sumDigits ( int n ) { int sum = 0 ; while ( n > 0 ) { int digit = n % 10 ; sum += digit ; n /= 10 ; } return sum ; } static boolean isDivBySix ( String str , int n ) { int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { sum += ( int ) ( str . charAt ( i ) - ' a ' + 1 ) ; } if ( sum % 3 != 0 ) return false ; int lastDigit = ( ( int ) ( str . charAt ( n - 1 ) - ' a ' + 1 ) ) % 10 ; if ( lastDigit % 2 != 0 ) return false ; return true ; } public static void main ( String [ ] args ) { String str = " ab " ; int n = str . length ( ) ; if ( isDivBySix ( str , n ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } }

Accumulator variables: i, n, sum
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static char [ ] CHARS = "0123456789ABCDEF " . toCharArray ( ) ; static int DIGITS = 16 ; static boolean isDivisible ( String s , int m ) { Map < Character , Integer > mp = new HashMap < > ( ) ; for ( int i = 0 ; i < DIGITS ; i ++ ) { mp . put ( CHARS [ i ] , i ) ; } int r = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { r = ( r * 16 + mp . get ( s . charAt ( i ) ) ) % m ; } if ( r == 0 ) return true ; return false ; } public static void main ( String [ ] args ) { String s = "10" ; int m = 3 ; if ( isDivisible ( s , m ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int cntSplits ( String s ) { if ( s . charAt ( s . length ( ) - 1 ) == '1' ) return - 1 ; int ans = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) ans += ( s . charAt ( i ) == '0' ) ? 1 : 0 ; return ans ; } public static void main ( String [ ] args ) { String s = "10010" ; System . out . println ( cntSplits ( s ) ) ; } }

Accumulator variables: ans, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static String CHARS = " qwertyuiopasdfghjklzxcvbnm " ; static int MAX = 26 ; static String getString ( char [ ] str , int n ) { Map < Character , Character > uMap = new HashMap < > ( ) ; for ( int i = 0 ; i < MAX ; i ++ ) { uMap . put ( CHARS . charAt ( i ) , CHARS . charAt ( ( i + 1 ) % MAX ) ) ; } for ( int i = 0 ; i < n ; i ++ ) { str [ i ] = uMap . get ( str [ i ] ) ; } return String . valueOf ( str ) ; } public static void main ( String [ ] args ) { String str = " geeks " ; int n = str . length ( ) ; System . out . println ( getString ( str . toCharArray ( ) , n ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static class Item { int min , max ; int total , sum ; Item ( int price ) { min = price ; max = price ; total = 1 ; this . sum = price ; } } static void findPrices ( String item [ ] , int price [ ] , int n ) { HashMap < String , Item > map = new HashMap < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( map . containsKey ( item [ i ] ) ) { Item currItem = map . get ( item [ i ] ) ; currItem . min = Math . min ( currItem . min , price [ i ] ) ; currItem . max = Math . max ( currItem . max , price [ i ] ) ; currItem . total ++ ; currItem . sum += price [ i ] ; } else { Item currItem = new Item ( price [ i ] ) ; map . put ( item [ i ] , currItem ) ; } } System . out . println ( " Item ▁ Min ▁ Max ▁ Average " ) ; for ( Map . Entry < String , Item > ob : map . entrySet ( ) ) { String key = ob . getKey ( ) ; Item currItem = ob . getValue ( ) ; System . out . println ( key + " ▁ " + currItem . min + " ▁ " + currItem . max + " ▁ " + ( ( float ) currItem . sum / ( float ) currItem . total ) ) ; } } public static void main ( String args [ ] ) { String item [ ] = { " toy " , " pen " , " notebook " , " pen " } ; int n = item . length ; int price [ ] = { 2 , 1 , 3 , 2 } ; findPrices ( item , price , n ) ; } }

Index/key variables: i
Accumulator variables: i, sum, total
Iterator variables: i
Class/struct names: GFG, Item
Java program:
class GFG { static int Count ( String s , int pos ) { int c = s . charAt ( pos - 1 ) ; int counter = 0 ; for ( int i = 0 ; i < pos - 1 ; i ++ ) { if ( s . charAt ( i ) == c ) counter = counter + 1 ; } return counter ; } public static void main ( String [ ] args ) { String s = " abacsddaa " ; int pos ; int n = s . length ( ) ; int query [ ] = { 9 , 3 , 2 } ; int Q = query . length ; for ( int i = 0 ; i < Q ; i ++ ) { pos = query [ i ] ; System . out . println ( Count ( s , pos ) ) ; } } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void Count ( int [ ] temp ) { int [ ] query = { 9 , 3 , 2 } ; int Q = query . length ; for ( int i = 0 ; i < Q ; i ++ ) { int pos = query [ i ] ; System . out . println ( temp [ pos - 1 ] ) ; } } static int [ ] processing ( String s , int len ) { int [ ] temp = new int [ len ] ; HashMap < Character , Integer > d = new HashMap < Character , Integer > ( ) ; for ( int i = 0 ; i < len ; i ++ ) { if ( ! d . containsKey ( s . charAt ( i ) ) ) { d . put ( s . charAt ( i ) , i ) ; } else { temp [ i ] = temp [ d . get ( s . charAt ( i ) ) ] + 1 ; d . put ( s . charAt ( i ) , i ) ; } } return temp ; } public static void main ( String [ ] args ) { String s = " abacsddaa " ; int n = s . length ( ) ; int [ ] temp = processing ( s , n ) ; Count ( temp ) ; } }

Index/key variables: i, len
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int sticks [ ] = { 6 , 2 , 5 , 5 , 4 , 5 , 6 , 3 , 7 , 6 } ; static int countSticks ( String str , int n ) { int cnt = 0 ; for ( int i = 0 ; i < n ; i ++ ) { cnt += ( sticks [ str . charAt ( i ) - '0' ] ) ; } return cnt ; } public static void main ( String [ ] args ) { String str = "56" ; int n = str . length ( ) ; System . out . println ( countSticks ( str , n ) ) ; } }

Accumulator variables: cnt, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void printChar ( char [ ] arr , int len ) { HashMap < Character , Integer > occ = new HashMap < Character , Integer > ( ) ; for ( int i = 0 ; i < len ; i ++ ) if ( occ . containsKey ( arr [ i ] ) ) { occ . put ( arr [ i ] , occ . get ( arr [ i ] ) + 1 ) ; } else { occ . put ( arr [ i ] , 1 ) ; } int size = occ . size ( ) ; while ( size -- > 0 ) { int currentMax = 0 ; char arg_max = 0 ; for ( Map . Entry < Character , Integer > it : occ . entrySet ( ) ) { if ( it . getValue ( ) > currentMax || ( it . getValue ( ) == currentMax && it . getKey ( ) > arg_max ) ) { arg_max = it . getKey ( ) ; currentMax = it . getValue ( ) ; } } System . out . print ( arg_max + " ▁ - ▁ " + currentMax + "NEW_LINE"); occ . remove ( arg_max ) ; } } public static void main ( String [ ] args ) { String str = " geeksforgeeks " ; int len = str . length ( ) ; printChar ( str . toCharArray ( ) , len ) ; } }

Index/key variables: i
Accumulator variables: i, size
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int getMod ( String str , int n , int k ) { int pwrTwo [ ] = new int [ n ] ; pwrTwo [ 0 ] = 1 % k ; for ( int i = 1 ; i < n ; i ++ ) { pwrTwo [ i ] = pwrTwo [ i - 1 ] * ( 2 % k ) ; pwrTwo [ i ] %= k ; } int res = 0 ; int i = 0 , j = n - 1 ; while ( i < n ) { if ( str . charAt ( j ) == '1' ) { res += ( pwrTwo [ i ] ) ; res %= k ; } i ++ ; j -- ; } return res ; } public static void main ( String [ ] args ) { String str = "1101" ; int n = str . length ( ) ; int k = 45 ; System . out . print ( getMod ( str , n , k ) ) ; } }

Index/key variables: i, n
Accumulator variables: i, j, res
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { final static int MOD = 1000000007 ; static long countStrings ( int N ) { int i , j ; int dp [ ] [ ] = new int [ N + 1 ] [ 3 ] ; for ( i = 0 ; i < N + 1 ; i ++ ) { for ( j = 9 ; j < 3 ; j ++ ) { dp [ i ] [ j ] = 0 ; } } dp [ 1 ] [ 0 ] = 1 ; dp [ 1 ] [ 1 ] = 1 ; dp [ 1 ] [ 2 ] = 0 ; for ( i = 2 ; i <= N ; i ++ ) { dp [ i ] [ 0 ] = ( dp [ i - 1 ] [ 0 ] + dp [ i - 1 ] [ 1 ] + dp [ i - 1 ] [ 2 ] ) % MOD ; dp [ i ] [ 1 ] = dp [ i - 1 ] [ 0 ] % MOD ; dp [ i ] [ 2 ] = dp [ i - 1 ] [ 1 ] % MOD ; } int ans = ( dp [ N ] [ 0 ] + dp [ N ] [ 1 ] + dp [ N ] [ 2 ] ) % MOD ; return ans ; } public static void main ( String [ ] args ) { int N = 3 ; System . out . println ( countStrings ( N ) ) ; } }

Index/key variables: N, i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static String maxNumber ( String str , int n ) { int [ ] freq = new int [ 2 ] ; for ( int i = 0 ; i < n ; i ++ ) { if ( str . charAt ( i ) == ' z ' ) freq [ 0 ] ++ ; else if ( str . charAt ( i ) == ' n ' ) freq [ 1 ] ++ ; } String num = " " ; for ( int i = 0 ; i < freq [ 1 ] ; i ++ ) num += '1' ; for ( int i = 0 ; i < freq [ 0 ] ; i ++ ) num += '0' ; return num ; } public static void main ( String [ ] args ) { String str = " roenenzooe " ; int n = str . length ( ) ; System . out . println ( maxNumber ( str , n ) ) ; } }

Accumulator variables: i, num
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void result ( String s , int n ) { HashSet < String > st = new HashSet < String > ( ) ; for ( int i = 0 ; i < ( int ) s . length ( ) ; i ++ ) { String ans = " " ; for ( int j = i ; j < ( int ) s . length ( ) ; j ++ ) { ans += s . charAt ( j ) ; if ( ans . length ( ) == n ) { st . add ( ans ) ; break ; } } } for ( String it : st ) System . out . print ( it + " ▁ " ) ; } public static void main ( String [ ] args ) { String s = " abca " ; int n = 3 ; result ( s , n ) ; } }

Accumulator variables: ans, i, j
Iterator variables: i, it, j
Class/struct names: GFG