dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
class GFG { static boolean check ( String s , int k ) { for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) != s . charAt ( i % k ) ) { return false ; } } return true ; } static int countCommonDivisors ( String a , String b ) { int ct = 0 ; int n = a . length ( ) , m = b . length ( ) ; for ( int i = 1 ; i <= Math . min ( n , m ) ; i ++ ) { if ( n % i == 0 && m % i == 0 ) { if ( a . substring ( 0 , i ) . equals ( b . substring ( 0 , i ) ) ) { if ( check ( a , i ) && check ( b , i ) ) { ct ++ ; } } } } return ct ; } public static void main ( String [ ] args ) { String a = " xaxa " , b = " xaxaxaxa " ; System . out . println ( countCommonDivisors ( a , b ) ) ; } }

Accumulator variables: ct, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . LinkedList ; import java . util . Queue ; public class GFG { static class Node { int data ; Node left ; Node right ; Node ( int data ) { this . data = data ; left = null ; right = null ; } } static void levelOrder ( Node root ) { if ( root == null ) return ; Queue < Node > q = new LinkedList < > ( ) ; q . add ( root ) ; q . add ( null ) ; while ( ! q . isEmpty ( ) ) { Node curr = q . poll ( ) ; if ( curr == null ) { if ( ! q . isEmpty ( ) ) { q . add ( null ) ; System . out . println ( ) ; } } else { if ( curr . left != null ) q . add ( curr . left ) ; if ( curr . right != null ) q . add ( curr . right ) ; System . out . print ( curr . data + " ▁ " ) ; } } } public static void main ( String [ ] args ) { Node root = new Node ( 1 ) ; root . left = new Node ( 2 ) ; root . right = new Node ( 3 ) ; root . left . left = new Node ( 4 ) ; root . left . right = new Node ( 5 ) ; root . right . right = new Node ( 6 ) ; levelOrder ( root ) ; } }

Class/struct names: GFG, Node
Java program:
class GFG { static int nextZero ( int i , int occurrences [ ] ) { while ( i < occurrences . length ) { if ( occurrences [ i ] == 0 ) return i ; i ++ ; } return - 1 ; } static String getModifiedString ( String str ) { int n = str . length ( ) ; if ( n > 26 ) return " - 1" ; char ch [ ] = str . toCharArray ( ) ; int i , occurrences [ ] = new int [ 26 ] ; for ( i = 0 ; i < n ; i ++ ) occurrences [ ch [ i ] - ' a ' ] ++ ; int index = nextZero ( 0 , occurrences ) ; for ( i = 0 ; i < n ; i ++ ) { if ( occurrences [ ch [ i ] - ' a ' ] > 1 ) { occurrences [ ch [ i ] - ' a ' ] -- ; ch [ i ] = ( char ) ( ' a ' + index ) ; occurrences [ index ] = 1 ; index = nextZero ( index + 1 , occurrences ) ; } } return String . valueOf ( ch ) ; } public static void main ( String arr [ ] ) { String str = " geeksforgeeks " ; System . out . print ( getModifiedString ( str ) ) ; } }

Index/key variables: i, index
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { static String extractSecretMessage ( String Str , String Sub ) { Str = Str . replaceAll ( Sub , " ▁ " ) ; Str = Str . trim ( ) ; return Str ; } public static void main ( String args [ ] ) { String Str = " LIELIEILIEAMLIECOOL " ; String Sub = " LIE " ; System . out . println ( extractSecretMessage ( Str , Sub ) ) ; } }

Class/struct names: GFG
Java program:
public class GFG { public static int subStringsStartingHere ( String str , int n , int startIndex ) { int count = 0 , i = startIndex + 1 ; while ( i <= n ) { if ( str . startsWith ( str . substring ( startIndex , i ) ) ) { count ++ ; } else break ; i ++ ; } return count ; } public static int countSubStrings ( String str , int n ) { int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( str . charAt ( i ) == str . charAt ( 0 ) ) count += subStringsStartingHere ( str , n , i ) ; } return count ; } public static void main ( String [ ] args ) { String str = " ababc " ; int n = str . length ( ) ; System . out . println ( countSubStrings ( str , n ) ) ; } }

Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int binarySearch ( String [ ] arr , String x ) { int l = 0 , r = arr . length - 1 ; while ( l <= r ) { int m = l + ( r - l ) / 2 ; int res = x . compareTo ( arr [ m ] ) ; if ( res == 0 ) return m ; if ( res > 0 ) l = m + 1 ; else r = m - 1 ; } return - 1 ; } public static void main ( String [ ] args ) { String [ ] arr = { " contribute " , " geeks " , " ide " , " practice " } ; String x = " ide " ; int result = binarySearch ( arr , x ) ; if ( result == - 1 ) System . out . println ( " Element ▁ not ▁ present " ) ; else System . out . println ( " Element ▁ found ▁ at ▁ " + " index ▁ " + result ) ; } }

Index/key variables: m
Class/struct names: GFG
Java program:
class Solution { static final int max_val = 257 ; static int PrimeCharacters ( String s ) { boolean prime [ ] = new boolean [ max_val + 1 ] ; for ( int i = 0 ; i <= max_val ; i ++ ) prime [ i ] = true ; prime [ 0 ] = false ; prime [ 1 ] = false ; for ( int p = 2 ; p * p <= max_val ; p ++ ) { if ( prime [ p ] == true ) { for ( int i = p * 2 ; i <= max_val ; i += p ) prime [ i ] = false ; } } int count = 0 ; for ( int i = 0 ; i < s . length ( ) ; ++ i ) { if ( prime [ ( int ) ( s . charAt ( i ) ) ] ) count ++ ; } return count ; } public static void main ( String args [ ] ) { String S = " geeksforgeeks " ; System . out . print ( PrimeCharacters ( S ) ) ; } }

Index/key variables: i, p
Accumulator variables: count, i, p
Iterator variables: i, p
Class/struct names: Solution
Java program:
import java . io . * ; import java . util . * ; import java . lang . * ; class GFG { static void getStudentsList ( String [ ] file ) { int avgScore ; int maxAvgScore = Integer . MIN_VALUE ; ArrayList < String > names = new ArrayList < > ( ) ; for ( int i = 0 ; i < file . length ; i += 4 ) { avgScore = ( Integer . parseInt ( file [ i + 1 ] ) + Integer . parseInt ( file [ i + 2 ] ) + Integer . parseInt ( file [ i + 3 ] ) ) / 3 ; if ( avgScore > maxAvgScore ) { maxAvgScore = avgScore ; names . clear ( ) ; names . add ( file [ i ] ) ; } else if ( avgScore == maxAvgScore ) names . add ( file [ i ] ) ; } for ( int i = 0 ; i < names . size ( ) ; i ++ ) { System . out . print ( names . get ( i ) + " ▁ " ) ; } System . out . print ( maxAvgScore ) ; } public static void main ( String args [ ] ) { String [ ] file = { " Shrikanth " , "20" , "30" , "10" , " Ram " , "100" , "50" , "10" } ; getStudentsList ( file ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int MAX_LEN = 1005 ; static int MAX_CHAR = 26 ; static int ALL_CHARS = 256 ; static boolean compare ( char [ ] arr1 , char [ ] arr2 ) { for ( int i = 0 ; i < ALL_CHARS ; i ++ ) if ( arr1 [ i ] != arr2 [ i ] ) return false ; return true ; } static boolean search ( String pat , String txt ) { int M = pat . length ( ) ; int N = txt . length ( ) ; int i ; char countP [ ] = new char [ ALL_CHARS ] ; char countTW [ ] = new char [ ALL_CHARS ] ; for ( i = 0 ; i < M ; i ++ ) { ( countP [ pat . charAt ( i ) ] ) ++ ; ( countTW [ txt . charAt ( i ) ] ) ++ ; } for ( i = M ; i < N ; i ++ ) { if ( compare ( countP , countTW ) ) { return true ; } ( countTW [ txt . charAt ( i ) ] ) ++ ; countTW [ txt . charAt ( i - M ) ] -- ; } if ( compare ( countP , countTW ) ) return true ; return false ; } static int calculatesubString ( String s1 , String s2 , int n ) { int count = 0 , j = 0 , x = 0 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int len = 1 ; len <= n - i ; len ++ ) { if ( search ( s1 . substring ( i , i + len ) , s2 ) ) { count = count + 1 ; } } } return count ; } public static void main ( String args [ ] ) { String str1 = " PLEASEHELPIMTRAPPED " ; String str2 = " INAKICKSTARTFACTORY " ; int len = str1 . length ( ) ; System . out . println ( calculatesubString ( str1 , str2 , len ) ) ; } }

Index/key variables: ALL_CHARS, i
Accumulator variables: i, len
Iterator variables: i, len
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int strScore ( String str [ ] , String s , int n ) { int score = 0 , index = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( str [ i ] == s ) { for ( int j = 0 ; j < s . length ( ) ; j ++ ) score += s . charAt ( j ) - ' a ' + 1 ; index = i + 1 ; break ; } } score = score * index ; return score ; } public static void main ( String [ ] args ) { String str [ ] = { " sahil " , " shashanak " , " sanjit " , " abhinav " , " mohit " } ; String s = " abhinav " ; int n = str . length ; int score = strScore ( str , s , n ) ; System . out . println ( score ) ; } }

Index/key variables: i
Accumulator variables: i, j, score
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static boolean sameJavaharAdj ( char str [ ] ) { int n = str . length , i ; TreeSet < Character > st = new TreeSet < > ( ) ; st . add ( str [ 0 ] ) ; for ( i = 1 ; i < n ; i ++ ) { if ( str [ i ] == str [ i - 1 ] ) { continue ; } if ( st . contains ( str [ i ] ) & ( str [ i ] != st . last ( ) ) ) { return false ; } st . add ( str [ i ] ) ; } return true ; } static int minSwaps ( char str [ ] , int l , int r , int cnt , int minm ) { if ( l == r ) { if ( sameJavaharAdj ( str ) ) { return cnt ; } else { return Integer . MAX_VALUE ; } } for ( int i = l + 1 ; i <= r ; i ++ ) { swap ( str , i , l ) ; cnt ++ ; int x = minSwaps ( str , l + 1 , r , cnt , minm ) ; swap ( str , i , l ) ; cnt -- ; int y = minSwaps ( str , l + 1 , r , cnt , minm ) ; minm = Math . min ( minm , Math . min ( x , y ) ) ; } return minm ; } static void swap ( char [ ] arr , int i , int j ) { char temp = arr [ i ] ; arr [ i ] = arr [ j ] ; arr [ j ] = temp ; } public static void main ( String [ ] args ) { String str = " abbaacb " ; int n = str . length ( ) , cnt = 0 , minm = Integer . MAX_VALUE ; System . out . print ( minSwaps ( str . toCharArray ( ) , 0 , n - 1 , cnt , minm ) ) ; ; } }

Index/key variables: i, j
Accumulator variables: cnt, i
Iterator variables: i
Class/struct names: GFG
Java program:
static int find ( int parent [ ] , int i ) { if ( parent [ i ] == - 1 ) return i ; return find ( parent , parent [ i ] ) ; } static void Union ( int parent [ ] , int x , int y ) { int xset = find ( parent , x ) ; int yset = find ( parent , y ) ; parent [ xset ] = yset ; }

Index/key variables: i, xset
Java program:
class GFG { static String K_thletter ( String S , int K ) { int N = S . length ( ) ; long size = 0 ; for ( int i = 0 ; i < N ; ++ i ) { if ( Character . isDigit ( S . charAt ( i ) ) ) { size = size * ( S . charAt ( i ) - '0' ) ; } else { size += 1 ; } } for ( int i = N - 1 ; i >= 0 ; -- i ) { K %= size ; if ( K == 0 && Character . isAlphabetic ( S . charAt ( i ) ) ) { return ( String ) " " + S . charAt ( i ) ; } if ( Character . isDigit ( S . charAt ( i ) ) ) { size = size / ( S . charAt ( i ) - '0' ) ; } else { size -= 1 ; } } return null ; } public static void main ( String [ ] args ) { String S = " geeks2for2" ; int K = 15 ; System . out . println ( K_thletter ( S , K ) ) ; } }

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

Accumulator variables: ans, bal
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static String reverse ( String input ) { char [ ] a = input . toCharArray ( ) ; int l , r = 0 ; r = a . length - 1 ; for ( l = 0 ; l < r ; l ++ , r -- ) { char temp = a [ l ] ; a [ l ] = a [ r ] ; a [ r ] = temp ; } return String . valueOf ( a ) ; } static boolean isPalindrome ( String r ) { String p = r ; p = reverse ( p ) ; return ( r . equals ( p ) ) ; } static boolean CheckStr ( String s ) { int l = s . length ( ) ; int i ; for ( i = 2 ; i <= l ; i ++ ) { if ( isPalindrome ( s . substring ( 0 , i ) ) ) { break ; } } if ( i == ( l + 1 ) ) { return false ; } i = 2 ; for ( i = 2 ; i <= l ; i ++ ) { if ( isPalindrome ( s . substring ( l - i , l ) ) ) { return true ; } } return false ; } public static void main ( String args [ ] ) { String s = " abccbarfgdbd " ; if ( CheckStr ( s ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } }

Index/key variables: l, r
Accumulator variables: i, l, r
Iterator variables: i, l
Class/struct names: GFG
Java program:
class solution { static int oddEquivalent ( String s , int n ) { int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( s . charAt ( i ) == '1' ) count ++ ; } return count ; } public static void main ( String ar [ ] ) { String s = "1011011" ; int n = s . length ( ) ; System . out . println ( oddEquivalent ( s , n ) ) ; } }

Accumulator variables: count, i
Iterator variables: i
Class/struct names: solution
Java program:
import java . util . * ; import java . lang . * ; import java . io . * ; class GFG { static final int MAX = 256 ; static int minimumOperation ( String s ) { int n = s . length ( ) ; Vector < Integer > first_occ = new Vector < Integer > ( ) ; for ( int i = 0 ; i < MAX ; i ++ ) first_occ . add ( i , - 1 ) ; int res = Integer . MAX_VALUE ; for ( int i = 0 ; i < n ; i ++ ) { int x = ( int ) s . charAt ( i ) ; if ( first_occ . elementAt ( x ) == - 1 ) first_occ . set ( x , i ) ; else { int last_occ = ( n - i - 1 ) ; res = Math . min ( res , first_occ . get ( x ) + last_occ ) ; } } return res ; } public static void main ( String args [ ] ) { String s = " bacdefghipalop " ; System . out . println ( minimumOperation ( s ) ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
public class GFG { public static void getSmallestAndLargest ( String s , int k ) { String currStr = s . substring ( 0 , k ) ; String lexMin = currStr ; String lexMax = currStr ; for ( int i = k ; i < s . length ( ) ; i ++ ) { currStr = currStr . substring ( 1 , k ) + s . charAt ( i ) ; if ( lexMax . compareTo ( currStr ) < 0 ) lexMax = currStr ; if ( lexMin . compareTo ( currStr ) > 0 ) lexMin = currStr ; } System . out . println ( lexMin ) ; System . out . println ( lexMax ) ; } public static void main ( String [ ] args ) { String str = " GeeksForGeeks " ; int k = 3 ; getSmallestAndLargest ( str , k ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class Initials { public static void printInitials ( String str ) { int len = str . length ( ) ; str = str . trim ( ) ; String t = " " ; for ( int i = 0 ; i < len ; i ++ ) { char ch = str . charAt ( i ) ; if ( ch != ' ▁ ' ) { t = t + ch ; } else { System . out . print ( Character . toUpperCase ( t . charAt ( 0 ) ) + " . ▁ " ) ; t = " " ; } } String temp = " " ; for ( int j = 0 ; j < t . length ( ) ; j ++ ) { if ( j == 0 ) temp = temp + Character . toUpperCase ( t . charAt ( 0 ) ) ; else temp = temp + Character . toLowerCase ( t . charAt ( j ) ) ; } System . out . println ( temp ) ; } public static void main ( String [ ] args ) { String str = " ishita ▁ bhuiya " ; printInitials ( str ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: Initials
Java program:
class GFG { static int findNumberOfTimes ( String str1 , String str2 ) { int freq [ ] = new int [ 26 ] ; int freq2 [ ] = new int [ 26 ] ; int l1 = str1 . length ( ) ; for ( int i = 0 ; i < l1 ; i ++ ) { freq [ str1 . charAt ( i ) - ' a ' ] += 1 ; } int l2 = str2 . length ( ) ; for ( int i = 0 ; i < l2 ; i ++ ) { freq2 [ str2 . charAt ( i ) - ' a ' ] += 1 ; } int count = Integer . MAX_VALUE ; for ( int i = 0 ; i < l2 ; i ++ ) { if ( freq2 [ str2 . charAt ( i ) - ' a ' ] != 0 ) count = Math . min ( count , freq [ str2 . charAt ( i ) - ' a ' ] / freq2 [ str2 . charAt ( i ) - ' a ' ] ) ; } return count ; } public static void main ( String [ ] args ) { String str1 = " foreeksgekseg " ; String str2 = " geeks " ; System . out . println ( findNumberOfTimes ( str1 , str2 ) ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { static boolean solve ( String s1 , String s2 ) { boolean flag1 = false , flag2 = false ; if ( s1 . length ( ) != s2 . length ( ) ) return false ; int l = s1 . length ( ) ; for ( int i = 0 ; i < l ; i ++ ) { if ( s1 . charAt ( i ) == '1' ) flag1 = true ; if ( s2 . charAt ( i ) == '1' ) flag2 = true ; if ( flag1 == true && flag2 == true ) return true ; } if ( ! flag1 && ! flag2 ) return true ; return false ; } public static void main ( String args [ ] ) { String s1 = "100101" ; String s2 = "100000" ; if ( solve ( s1 , s2 ) == true ) System . out . print ( " Yes " ) ; else System . out . print ( " No " ) ; } }

Accumulator variables: i
Iterator variables: i
Boolean variables: flag1, flag2
Class/struct names: GFG
Java program:
class GFG { static char nextGreatestAlphabet ( char alphabets [ ] , char K ) { int n = alphabets . length ; if ( K >= alphabets [ n - 1 ] ) return alphabets [ 0 ] ; int l = 0 , r = alphabets . length - 1 ; int ans = - 1 ; while ( l <= r ) { int mid = ( l + r ) / 2 ; if ( alphabets [ mid ] > K ) { r = mid - 1 ; ans = mid ; } else l = mid + 1 ; } return alphabets [ ans ] ; } public static void main ( String [ ] args ) { char letters [ ] = { ' A ' , ' r ' , ' z ' } ; char K = ' z ' ; char result = nextGreatestAlphabet ( letters , K ) ; System . out . println ( result ) ; } }

Index/key variables: ans, mid
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; import java . lang . * ; class GfG { public static int subzero ( String s , int k ) { int ans = 0 , curr = 0 ; int len = s . length ( ) ; char [ ] str = s . toCharArray ( ) ; for ( int i = 0 ; i < len ; ++ i ) { if ( str [ i ] == '0' ) curr ++ ; else curr = 0 ; ans = Math . max ( ans , curr ) ; } if ( ans == len ) return len * k ; else { int pre = 0 , suff = 0 ; for ( int i = 0 ; i < len ; i ++ ) { if ( str [ i ] == '0' ) pre ++ ; else break ; } for ( int i = len - 1 ; i >= 0 ; i -- ) { if ( str [ i ] == '0' ) suff ++ ; else break ; } if ( k > 1 ) ans = Math . max ( ans , pre + suff ) ; return ans ; } } public static void main ( String [ ] args ) { String str = "00100110" ; int k = 5 ; System . out . println ( subzero ( str , k ) ) ; } }

Index/key variables: i
Accumulator variables: curr, i, pre, suff
Iterator variables: i
Class/struct names: GfG
Java program:
import java . util . * ; class solution { static String Dragon_Curve_Sequence ( int n ) { String s = "1" ; for ( int i = 2 ; i <= n ; i ++ ) { String temp = "1" ; char prev = '1' , zero = '0' , one = '1' ; for ( int j = 0 ; j < s . length ( ) ; j ++ ) { temp += s . charAt ( j ) ; if ( prev == '0' ) { temp += one ; prev = one ; } else { temp += zero ; prev = zero ; } } s = temp ; } return s ; } public static void main ( String args [ ] ) { int n = 4 ; String s = Dragon_Curve_Sequence ( n ) ; System . out . println ( s ) ; } }

Accumulator variables: i, j, temp
Iterator variables: i, j
Class/struct names: solution
Java program:
import java . io . * ; public class GFG { static int countNonEmptySubstr ( String str ) { int n = str . length ( ) ; return n * ( n + 1 ) / 2 ; } public static void main ( String args [ ] ) { String s = " abcde " ; System . out . println ( countNonEmptySubstr ( s ) ) ; } }

Class/struct names: GFG
Java program:
import java . util . Arrays ; class GFG { static int findSubstrings ( String s , int k ) { int ans = 0 ; int cnt [ ] = new int [ 26 ] ; int i , j , n = s . length ( ) ; for ( i = 0 ; i < n ; i ++ ) { Arrays . fill ( cnt , 0 ) ; for ( j = i ; j < n ; j ++ ) { cnt [ s . charAt ( j ) - ' a ' ] ++ ; if ( cnt [ s . charAt ( j ) - ' a ' ] <= k ) { ans ++ ; else { break ; } } } return ans ; } static public void main ( String [ ] args ) { String S = " aaabb " ; int k = 2 ; System . out . println ( findSubstrings ( S , k ) ) ; } }

Accumulator variables: ans, i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
class GFG { static int MAX = 26 ; static boolean targetstring ( String str1 , String str2 ) { int l1 = str1 . length ( ) ; int l2 = str2 . length ( ) ; if ( l1 != l2 ) return false ; int [ ] map = new int [ MAX ] ; for ( int i = 0 ; i < l1 ; i ++ ) map [ str1 . charAt ( i ) - ' a ' ] ++ ; for ( int i = 0 ; i < l2 ; i ++ ) { map [ str2 . charAt ( i ) - ' a ' ] -- ; if ( map [ str2 . charAt ( i ) - ' a ' ] < 0 ) return false ; } return true ; } public static void main ( String args [ ] ) { String str1 = " geeksforgeeks " ; String str2 = " geegeeksksfor " ; if ( targetstring ( str1 , str2 ) ) System . out . print ( " YES " ) ; else System . out . print ( " NO " ) ; } }

Index/key variables: MAX
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static boolean isDigitPresent ( int x , int d ) { while ( x > 0 ) { if ( x % 10 == d ) break ; x = x / 10 ; } return ( x > 0 ) ; } static void printNumbers ( int n , int d ) { for ( int i = 0 ; i <= n ; i ++ ) if ( i == d || isDigitPresent ( i , d ) ) System . out . print ( i + " ▁ " ) ; } public static void main ( String [ ] args ) { int n = 47 , d = 7 ; printNumbers ( n , d ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static char findExtraCharcter ( char [ ] strA , char [ ] strB ) { int [ ] m1 = new int [ 256 ] ; for ( int i = 0 ; i < strB . length ; i ++ ) m1 [ strB [ i ] ] ++ ; for ( int i = 0 ; i < strA . length ; i ++ ) m1 [ strA [ i ] ] -- ; for ( int i = 0 ; i < m1 . length ; i ++ ) { if ( m1 [ i ] == 1 ) return ( char ) i ; } return Character . MIN_VALUE ; } public static void main ( String [ ] args ) { String strA = " abcd " ; String strB = " cbdad " ; System . out . println ( findExtraCharcter ( strA . toCharArray ( ) , strB . toCharArray ( ) ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static char findExtraCharcter ( String strA , String strB ) { int res = 0 , i ; for ( i = 0 ; i < strA . length ( ) ; i ++ ) { res ^= strA . charAt ( i ) ; } for ( i = 0 ; i < strB . length ( ) ; i ++ ) { res ^= strB . charAt ( i ) ; } return ( ( char ) ( res ) ) ; } public static void main ( String args [ ] ) { String strA = " abcd " ; String strB = " cbdad " ; System . out . println ( findExtraCharcter ( strA , strB ) ) ; } }

Accumulator variables: i, res
Iterator variables: i
Class/struct names: GFG
Java program:
public class Test { private static char findExtraCharacter ( String s1 , String s2 ) { String smallStr ; String largeStr ; if ( s1 . length ( ) > s2 . length ( ) ) { smallStr = s2 ; largeStr = s1 ; } else { smallStr = s1 ; largeStr = s2 ; } int smallStrCodeTotal = 0 ; int largeStrCodeTotal = 0 ; int i = 0 ; for ( ; i < smallStr . length ( ) ; i ++ ) { smallStrCodeTotal += smallStr . charAt ( i ) ; largeStrCodeTotal += largeStr . charAt ( i ) ; } largeStrCodeTotal += largeStr . charAt ( i ) ; int intChar = largeStrCodeTotal - smallStrCodeTotal ; return ( char ) intChar ; } public static void main ( String [ ] args ) { String s1 = " abcd " ; String s2 = " cbdae " ; char extraChar = findExtraCharacter ( s1 , s2 ) ; System . out . println ( " Extra ▁ character : ▁ " + extraChar ) ; } }

Accumulator variables: i, largeStrCodeTotal, smallStrCodeTotal
Class/struct names: Test
Java program:
class GFG { static void myCopy ( char s1 [ ] , char s2 [ ] ) { int i = 0 ; for ( i = 0 ; i < s1 . length ; i ++ ) s2 [ i ] = s1 [ i ] ; } public static void main ( String [ ] args ) { char s1 [ ] = " GEEKSFORGEEKS " . toCharArray ( ) ; char s2 [ ] = new char [ s1 . length ] ; myCopy ( s1 , s2 ) ; System . out . println ( String . valueOf ( s2 ) ) ; } }

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