dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
import java . util . * ; class GFG { static boolean ischar ( char x ) { if ( ( x >= ' A ' && x <= ' Z ' ) || ( x >= ' a ' && x <= ' z ' ) ) { return true ; } return false ; } static boolean isnum ( char x ) { if ( x >= '0' && x <= '9' ) return true ; return false ; } static void findIdandDomain ( String S , int N ) { String ID = " " , Domain = " " ; Vector < String > words = new Vector < String > ( ) ; String curr = " " ; for ( int i = 0 ; i < N ; i ++ ) { if ( S . charAt ( i ) == ' ▁ ' ) { words . add ( curr ) ; curr = " " ; } else { if ( S . charAt ( i ) == ' . ' ) { if ( i + 1 == N || ( i + 1 < N && S . charAt ( i + 1 ) == ' ▁ ' ) ) continue ; } curr += S . charAt ( i ) ; } } if ( curr . length ( ) > 0 ) words . add ( curr ) ; for ( String ss : words ) { if ( ss . length ( ) == 10 ) { boolean flag = false ; for ( int j = 0 ; j <= 9 ; j ++ ) { if ( j >= 5 && j < 9 ) { if ( isnum ( ss . charAt ( j ) ) == false ) flag = true ; } else { if ( ischar ( ss . charAt ( j ) ) == false ) flag = true ; } } if ( ! flag ) { ID = ss ; } } if ( ss . length ( ) > 2 && ss . substring ( 0 , 3 ) . equals ( " www " ) && ss . substring ( ss . length ( ) - 3 ) . equals ( " com " ) ) { Domain = ss . substring ( 4 , ss . length ( ) ) ; } } System . out . print ( " ID ▁ = ▁ " + ID + "NEW_LINE"); System . out . print ( " Domain ▁ = ▁ " + Domain ) ; } public static void main ( String [ ] args ) { String S = " We ▁ thank ▁ ABCDE1234F ▁ for ▁ visiting ▁ " + " us ▁ and ▁ buying ▁ products ▁ item ▁ AMZrr @ ! k . ▁ " + " For ▁ more ▁ offers , ▁ visit ▁ us ▁ at ▁ www . amazon . com " ; int N = S . length ( ) ; findIdandDomain ( S , N ) ; } }

Accumulator variables: curr, i, j
Iterator variables: i, j, ss
Boolean variables: flag
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static boolean isValid ( int [ ] weight , int n , int D , int mx ) { int st = 1 ; int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { sum += weight [ i ] ; if ( sum > mx ) { st ++ ; sum = weight [ i ] ; } if ( st > D ) return false ; } return true ; } static void shipWithinDays ( int [ ] weight , int D , int n ) { int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) sum += weight [ i ] ; int s = weight [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) { s = Math . max ( s , weight [ i ] ) ; } int e = sum ; int res = - 1 ; while ( s <= e ) { int mid = s + ( e - s ) / 2 ; if ( isValid ( weight , n , D , mid ) ) { res = mid ; e = mid - 1 ; } else s = mid + 1 ; } System . out . println ( res ) ; } public static void main ( String [ ] args ) { int [ ] weight = { 9 , 8 , 10 } ; int D = 3 ; int N = weight . length ; shipWithinDays ( weight , D , N ) ; } }

Index/key variables: i
Accumulator variables: i, st, sum
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . lang . * ; import java . util . * ; public class GFG { static void createGraph ( HashMap < Integer , ArrayList < Integer > > adj , int paths [ ] [ ] , int A [ ] , int N , int E ) { for ( int i = 0 ; i < E ; i ++ ) { if ( A [ paths [ i ] [ 0 ] ] != 1 && A [ paths [ i ] [ 1 ] ] != 1 ) { ArrayList < Integer > list = adj . getOrDefault ( paths [ i ] [ 0 ] , new ArrayList < > ( ) ) ; list . add ( paths [ i ] [ 1 ] ) ; adj . put ( paths [ i ] [ 0 ] , list ) ; } } } static int minPath ( int paths [ ] [ ] , int A [ ] , int N , int E ) { if ( A [ 0 ] == 1 A [ N - 1 ] == 1 ) return - 1 ; HashMap < Integer , ArrayList < Integer > > adj = new HashMap < > ( ) ; createGraph ( adj , paths , A , N , E ) ; boolean visited [ ] = new boolean [ N ] ; int dist [ ] = new int [ N ] ; dist [ 0 ] = 0 ; ArrayDeque < Integer > q = new ArrayDeque < > ( ) ; q . addLast ( 0 ) ; visited [ 0 ] = true ; while ( ! q . isEmpty ( ) ) { int temp = q . removeFirst ( ) ; for ( int x : adj . getOrDefault ( temp , new ArrayList < > ( ) ) ) { if ( ! visited [ x ] ) { q . addLast ( x ) ; visited [ x ] = true ; dist [ x ] = dist [ temp ] + 1 ; } } } if ( ! visited [ N - 1 ] ) return - 1 ; else return dist [ N - 1 ] ; } public static void main ( String [ ] args ) { int N = 5 , E = 5 ; int A [ ] = { 0 , 1 , 0 , 0 , 0 } ; int paths [ ] [ ] = { { 0 , 1 } , { 0 , 2 } , { 1 , 4 } , { 2 , 3 } , { 3 , 4 } } ; System . out . print ( minPath ( paths , A , N , E ) ) ; } }

Index/key variables: N, i, temp, x
Accumulator variables: i
Iterator variables: i, x
Class/struct names: GFG
Java program:
import java . lang . * ; class GFG { public static int findSum ( int arr [ ] , int N , int pt ) { int sum = 0 ; for ( int i = 0 ; i < N ; i ++ ) { sum += Math . abs ( arr [ i ] - pt ) ; } return sum ; } public static void findPoint ( int arr [ ] , int N , int K ) { int left ; if ( N % 2 != 0 ) { left = arr [ N / 2 ] ; } else { left = arr [ N / 2 - 1 ] + 1 ; } int right = arr [ N - 1 ] ; while ( left <= right ) { int mid = ( left + right ) / 2 ; int temp = findSum ( arr , N , mid ) ; if ( temp == K ) { System . out . println ( mid ) ; return ; } else if ( K < temp ) { right = mid - 1 ; } else { left = mid + 1 ; } } left = arr [ 0 ] ; right = arr [ N / 2 ] - 1 ; while ( left <= right ) { int mid = ( left + right ) / 2 ; int temp = findSum ( arr , N , mid ) ; if ( temp == K ) { System . out . println ( mid ) ; return ; } else if ( K > temp ) { right = mid - 1 ; } else { left = mid + 1 ; } } System . out . println ( " - 1" ) ; } public static void main ( String args [ ] ) { int arr [ ] = { 1 , 3 , 6 , 7 , 11 } ; int K = 18 ; int N = arr . length ; findPoint ( arr , N , K ) ; } }

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { static void findArray ( int arr [ ] , int n ) { Vector < Integer > v = new Vector < Integer > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { int ans = - 1 , old_c = 0 ; for ( int j = i + 1 ; j < n ; j ++ ) { if ( arr [ j ] > arr [ i ] ) { int curr_c = 0 ; for ( int k = j ; k < n ; k ++ ) { if ( arr [ k ] == arr [ j ] ) { curr_c ++ ; } } ; if ( curr_c == old_c ) { if ( arr [ j ] < ans ) ans = arr [ j ] ; } if ( curr_c > old_c ) { ans = arr [ j ] ; old_c = curr_c ; } } } v . add ( ans ) ; } for ( int i = 0 ; i < v . size ( ) ; i ++ ) System . out . print ( v . get ( i ) + " ▁ " ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 4 , 5 , 2 , 25 , 10 , 5 , 10 , 3 , 10 , 5 } ; int size = arr . length ; findArray ( arr , size ) ; } }

Index/key variables: i, j, k
Accumulator variables: curr_c, i, j, k
Iterator variables: i, j, k
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void prodEquilibrium ( int arr [ ] , int N ) { int product = 1 ; for ( int i = 0 ; i < N ; i ++ ) { product *= arr [ i ] ; } int left = 1 ; int right = product ; for ( int i = 0 ; i < N ; i ++ ) { left = left * arr [ i ] ; right = right / arr [ i ] ; if ( left == right ) { System . out . print ( i + 1 + "NEW_LINE"); return ; } } System . out . print ( - 1 + "NEW_LINE"); } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 3 , 3 , 2 , 1 } ; int N = arr . length ; prodEquilibrium ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: i, product
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int countTriplets ( int D , int [ ] arr ) { HashMap < Integer , Integer > freq = new HashMap < Integer , Integer > ( ) ; int ans = 0 ; for ( int i = 0 ; i < arr . length ; i ++ ) { if ( freq . containsKey ( arr [ i ] - D ) && freq . containsKey ( arr [ i ] - 2 * D ) ) { ans += freq . get ( arr [ i ] - D ) * freq . get ( arr [ i ] - 2 * D ) ; } if ( freq . containsKey ( arr [ i ] ) ) { freq . put ( arr [ i ] , freq . get ( arr [ i ] ) + 1 ) ; } else { freq . put ( arr [ i ] , 1 ) ; } } return ans ; } public static void main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 4 , 5 , 7 , 8 , 10 } ; int D = 1 ; System . out . print ( countTriplets ( D , arr ) ) ; } }

Index/key variables: i
Accumulator variables: ans, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . lang . * ; import java . util . * ; class GFG { static int find_index ( int arr [ ] , int N ) { int max_value = Integer . MIN_VALUE ; for ( int i = 0 ; i < N ; i ++ ) { max_value = Math . max ( max_value , arr [ i ] ) ; } Map < Integer , Integer > store = new HashMap < > ( ) ; for ( int i = 1 ; i <= max_value ; i ++ ) { store . put ( i , store . getOrDefault ( i , 0 ) + 1 ) ; } if ( store . containsKey ( 1 ) ) { store . remove ( 1 ) ; } for ( int i = 2 ; i <= Math . sqrt ( max_value ) ; i ++ ) { int multiple = 2 ; while ( ( i * multiple ) <= max_value ) { if ( store . containsKey ( i * multiple ) ) { store . remove ( i * multiple ) ; } multiple ++ ; } } int prime_sum_from_left = 0 ; int [ ] first_array = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { first_array [ i ] = prime_sum_from_left ; if ( store . containsKey ( arr [ i ] ) ) { prime_sum_from_left += arr [ i ] ; } } int prime_sum_from_right = 0 ; int [ ] second_array = new int [ N ] ; for ( int i = N - 1 ; i >= 0 ; i -- ) { second_array [ i ] = prime_sum_from_right ; if ( store . containsKey ( arr [ i ] ) ) { prime_sum_from_right += arr [ i ] ; } } for ( int i = 0 ; i < N ; i ++ ) { if ( first_array [ i ] == second_array [ i ] ) { return i ; } } return - 1 ; } public static void main ( String [ ] args ) { int arr [ ] = { 11 , 4 , 7 , 6 , 13 , 1 , 5 } ; int N = arr . length ; System . out . println ( find_index ( arr , N ) ) ; } }

Index/key variables: N, i
Accumulator variables: i, multiple, prime_sum_from_left, prime_sum_from_right
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . lang . * ; import java . util . * ; public class GFG { static void convert ( int arr [ ] , int n ) { int brr [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) brr [ i ] = arr [ i ] ; Arrays . sort ( brr ) ; for ( int i = 0 ; i < n ; i ++ ) { int l = 0 , r = n - 1 , mid ; while ( l <= r ) { mid = ( l + r ) / 2 ; if ( brr [ mid ] == arr [ i ] ) { System . out . print ( mid + " ▁ " ) ; break ; } else if ( brr [ mid ] < arr [ i ] ) { l = mid + 1 ; } else { r = mid - 1 ; } } } } public static void main ( String [ ] args ) { int arr [ ] = { 10 , 20 , 15 , 12 , 11 , 50 } ; int N = arr . length ; convert ( arr , N ) ; } }

Index/key variables: i, mid, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . HashMap ; public class GFG { static int findIndex ( int arr [ ] , int N ) { int maxValue = Integer . MIN_VALUE ; for ( int i = 0 ; i < N ; i ++ ) { maxValue = Math . max ( maxValue , arr [ i ] ) ; } HashMap < Integer , Integer > St = new HashMap < > ( ) ; for ( int i = 1 ; i <= maxValue ; i ++ ) { St . put ( i , St . getOrDefault ( i , 0 ) + 1 ) ; } if ( St . containsKey ( 1 ) ) { St . remove ( 1 ) ; } for ( int i = 2 ; i <= Math . sqrt ( maxValue ) ; i ++ ) { int j = 2 ; while ( ( i * j ) <= maxValue ) { if ( St . containsKey ( i * j ) ) { St . remove ( i * j ) ; } j ++ ; } } int LeftCount = 0 ; int Prefix [ ] = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { Prefix [ i ] = LeftCount ; if ( St . containsKey ( arr [ i ] ) ) { LeftCount ++ ; } } int RightCount = 0 ; int Suffix [ ] = new int [ N ] ; for ( int i = N - 1 ; i >= 0 ; i -- ) { Suffix [ i ] = RightCount ; if ( St . containsKey ( arr [ i ] ) ) { RightCount ++ ; } } for ( int i = 0 ; i < N ; i ++ ) { if ( Prefix [ i ] == Suffix [ i ] ) { return i ; } } return - 1 ; } public static void main ( String [ ] args ) { int arr [ ] = { 2 , 3 , 4 , 7 , 5 , 10 , 1 , 8 } ; int N = arr . length ; System . out . println ( findIndex ( arr , N ) ) ; } }

Index/key variables: N, i
Accumulator variables: LeftCount, RightCount, i, j
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { public static int getCountPairs ( int arr [ ] , int N , int S ) { int count = 0 ; for ( int i = 0 ; i < arr . length ; i ++ ) { for ( int j = i + 1 ; j < arr . length ; j ++ ) { if ( ( arr [ i ] + arr [ j ] ) == S ) count ++ ; } } return count ; } public static int countPairs ( int arr [ ] , int N ) { int count = 0 ; HashSet < Integer > S = new HashSet < > ( ) ; for ( int i = 0 ; i < N ; i ++ ) S . add ( arr [ i ] ) ; for ( int ele : S ) { int sum = 2 * ele ; count += getCountPairs ( arr , N , sum ) ; } return count ; } public static void main ( String [ ] args ) { int arr [ ] = { 4 , 2 , 5 , 1 , 3 , 5 } ; int N = arr . length ; System . out . print ( countPairs ( arr , N ) ) ; } }

Index/key variables: i, j
Accumulator variables: count, i, j
Iterator variables: ele, i, j
Class/struct names: GFG
Java program:
import java . util . Vector ; public class GFG { static int MAX = ( int ) 1e5 ; public static class pair { long first ; long second ; pair ( long first , long second ) { this . first = first ; this . second = second ; } } static long power ( long x , long y ) { long res = 1 ; if ( x == 0 ) return 0 ; while ( y > 0 ) { if ( ( y & 1 ) == 1 ) res = ( res * x ) ; y = y >> 1 ; x = ( x * x ) ; } return res ; } static void SieveOfEratosthenes ( Vector < pair > v ) { boolean prime [ ] = new boolean [ MAX + 1 ] ; for ( int i = 0 ; i < prime . length ; i ++ ) { prime [ i ] = true ; } prime [ 1 ] = false ; for ( int p = 2 ; p * p <= MAX ; p ++ ) { if ( prime [ p ] == true ) { for ( int i = p * 2 ; i <= MAX ; i += p ) prime [ i ] = false ; } } int num = 1 ; for ( int i = 1 ; i <= MAX ; i ++ ) { if ( prime [ i ] ) { v . add ( new pair ( i , num ) ) ; num ++ ; } } } static long countIntegers ( long n ) { if ( n < 16 ) { return 0 ; } Vector < pair > v = new Vector < > ( ) ; SieveOfEratosthenes ( v ) ; int low = 0 ; int high = v . size ( ) - 1 ; while ( low <= high ) { int mid = ( low + high ) / 2 ; long curr = power ( v . get ( mid ) . first , 4 ) ; long prev = power ( v . get ( mid - 1 ) . first , 4 ) ; if ( curr == n ) { return v . get ( mid ) . second ; } else if ( curr > n && prev <= n ) { return v . get ( mid - 1 ) . second ; } else if ( curr > n ) { high = mid - 1 ; } else { low = mid + 1 ; } } return 0 ; } public static void main ( String [ ] args ) { long N = 100 ; System . out . println ( countIntegers ( N ) ) ; } }

Index/key variables: i, p
Accumulator variables: i, num, p
Iterator variables: i, p
Class/struct names: GFG, pair
Java program:
import java . io . * ; import java . lang . * ; import java . util . * ; class GFG { static boolean isPowerOfTwo ( int n ) { if ( n == 0 ) return false ; return ( Math . ceil ( Math . log ( n ) / Math . log ( 2 ) ) == Math . floor ( Math . log ( n ) / Math . log ( 2 ) ) ) ; } static void printArray ( ArrayList < String > res ) { Collections . sort ( res ) ; for ( int i = 0 ; i < res . size ( ) ; i ++ ) { System . out . print ( res . get ( i ) + " ▁ " ) ; } } static void sortedStrings ( String S [ ] , int N ) { HashMap < Character , Integer > freq = new HashMap < > ( ) ; ArrayList < String > res = new ArrayList < > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { String st = " " ; for ( int j = 0 ; j < S [ i ] . length ( ) ; j ++ ) { freq . put ( S [ i ] . charAt ( j ) , freq . getOrDefault ( S [ i ] . charAt ( j ) , 0 ) + 1 ) ; } for ( char ch : freq . keySet ( ) ) { if ( isPowerOfTwo ( freq . get ( ch ) ) ) { for ( int j = 0 ; j < freq . get ( ch ) ; j ++ ) { st += ch ; } } } freq . clear ( ) ; if ( st . length ( ) == 0 ) continue ; char myCharArr [ ] = st . toCharArray ( ) ; Arrays . sort ( myCharArr ) ; String ns = " " ; for ( int j = myCharArr . length - 1 ; j >= 0 ; -- j ) ns += myCharArr [ j ] ; res . add ( ns ) ; } printArray ( res ) ; } public static void main ( String [ ] args ) { String arr [ ] = { " aaacbb " , " geeks " , " aaa " } ; int N = arr . length ; sortedStrings ( arr , N ) ; } }

Index/key variables: i, j
Accumulator variables: i, j, ns, st
Iterator variables: ch, i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void replaceCharacters ( String s , char [ ] [ ] p ) { int n = s . length ( ) , k = p . length ; char [ ] arr = new char [ 26 ] ; char [ ] brr = new char [ 26 ] ; for ( int i = 0 ; i < n ; i ++ ) { arr [ s . charAt ( i ) - ' a ' ] = s . charAt ( i ) ; brr [ s . charAt ( i ) - ' a ' ] = s . charAt ( i ) ; } for ( int j = 0 ; j < k ; j ++ ) { char a = p [ j ] [ 0 ] , b = p [ j ] [ 1 ] ; for ( int i = 0 ; i < 26 ; i ++ ) { if ( arr [ i ] == a ) { brr [ i ] = b ; } } } for ( int i = 0 ; i < n ; i ++ ) { System . out . print ( brr [ s . charAt ( i ) - ' a ' ] ) ; } } public static void main ( String [ ] args ) { String S = " aabbgg " ; char [ ] [ ] P = { { ' a ' , ' b ' } , { ' b ' , ' g ' } , { ' g ' , ' a ' } } ; replaceCharacters ( S , P ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
class GFG { static int MAX = 100001 ; static void SieveOfEratosthenes ( boolean prime [ ] ) { prime [ 0 ] = false ; prime [ 1 ] = false ; for ( int p = 2 ; p * p < MAX ; p ++ ) { if ( prime [ p ] == true ) { for ( int i = p * p ; i < MAX ; i += p ) prime [ i ] = false ; } } } static void smallestSemiPrime ( int n ) { boolean [ ] prime = new boolean [ MAX ] ; for ( int i = 0 ; i < prime . length ; i ++ ) { prime [ i ] = true ; } SieveOfEratosthenes ( prime ) ; int num1 = n + 1 ; while ( prime [ num1 ] != true ) { num1 ++ ; } int num2 = num1 + n ; while ( prime [ num2 ] != true ) { num2 ++ ; } System . out . print ( num1 * num2 ) ; } public static void main ( String [ ] args ) { int N = 2 ; smallestSemiPrime ( N ) ; } }

Index/key variables: MAX, i, num1, num2, p
Accumulator variables: i, num1, num2, p
Iterator variables: i, p
Class/struct names: GFG
Java program:
import java . lang . * ; import java . util . * ; class GFG { static void productOfTwoPerfectCubes ( int N ) { Map < Integer , Integer > cubes = new HashMap < > ( ) ; for ( int i = 1 ; i * i * i <= N ; i ++ ) cubes . put ( i * i * i , i ) ; for ( Map . Entry < Integer , Integer > itr : cubes . entrySet ( ) ) { int firstNumber = itr . getKey ( ) ; if ( N % itr . getKey ( ) == 0 ) { int secondNumber = N / itr . getKey ( ) ; if ( cubes . containsKey ( secondNumber ) ) { System . out . println ( " Yes " ) ; return ; } } } System . out . println ( " No " ) ; } public static void main ( String [ ] args ) { int N = 216 ; productOfTwoPerfectCubes ( N ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . lang . * ; class GFG { public static void productOfTwoPerfectCubes ( double N ) { double cube_root ; cube_root = Math . round ( Math . cbrt ( N ) ) ; if ( cube_root * cube_root * cube_root == N ) { System . out . println ( " Yes " ) ; return ; } else { System . out . println ( " No " ) ; return ; } } public static void main ( String args [ ] ) { double N = 216 ; productOfTwoPerfectCubes ( N ) ; } }

Class/struct names: GFG
Java program:
class GFG { static boolean bound ( int w , int h , int N , int x ) { int val = ( x / w ) * ( x / h ) ; if ( val >= N ) return true ; else return false ; } static int FindSquare ( int N , int W , int H ) { int i = 1 ; int j = W * H * N ; while ( i < j ) { int mid = i + ( j - i ) / 2 ; if ( bound ( W , H , N , mid ) ) j = mid ; else i = mid + 1 ; } return j ; } public static void main ( String [ ] args ) { int W = 2 ; int H = 3 ; int N = 10 ; System . out . print ( FindSquare ( N , W , H ) ) ; } }

Class/struct names: GFG
Java program:
import java . util . HashSet ; public class GFG { static void printNumberOfPairs ( int N ) { HashSet < Integer > st = new HashSet < Integer > ( ) ; for ( int i = 2 ; i * i <= N ; i ++ ) { int x = i ; while ( x <= N ) { x *= i ; if ( x <= N ) { st . add ( x ) ; } } } System . out . println ( st . size ( ) ) ; } public static void main ( String args [ ] ) { int N = 10000 ; printNumberOfPairs ( N ) ; } }

Accumulator variables: i, x
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { public static int countSetBits ( int n ) { int count = 0 ; while ( n > 0 ) { count += n & 1 ; n >>= 1 ; } return count ; } public static void maximumProduct ( String [ ] words ) { int [ ] bits = new int [ words . length ] ; for ( int i = 0 ; i < words . length ; i ++ ) { for ( int j = 0 ; j < words [ i ] . length ( ) ; j ++ ) { bits [ i ] = bits [ i ] | 1 << ( words [ i ] . charAt ( j ) - ' a ' ) ; } } int result = 0 ; for ( int i = 0 ; i < bits . length ; i ++ ) { for ( int j = i + 1 ; j < bits . length ; j ++ ) { if ( ( bits [ i ] & bits [ j ] ) == 0 ) { int L = countSetBits ( bits [ i ] ) ; int R = countSetBits ( bits [ j ] ) ; result = Math . max ( L * R , result ) ; } } } System . out . println ( result ) ; } public static void main ( String [ ] args ) { String arr [ ] = { " abcw " , " baz " , " foo " , " bar " , " xtfn " , " abcdef " } ; maximumProduct ( arr ) ; } }

Index/key variables: i, j
Accumulator variables: count, i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static boolean palindrome ( String str ) { int st = 0 ; int ed = str . length ( ) - 1 ; while ( st < ed ) { if ( str . charAt ( st ) == str . charAt ( ed ) ) { st ++ ; ed -- ; } else return false ; } return true ; } static void printReverse ( String sentence ) { ArrayList < String > newlist = new ArrayList < String > ( ) ; ArrayList < String > lis = new ArrayList < String > ( ) ; String temp = " " ; for ( char x : sentence . toCharArray ( ) ) { if ( x == ' ▁ ' ) { lis . add ( temp ) ; temp = " " ; } else temp += x ; } lis . add ( temp ) ; for ( String x : lis ) { if ( palindrome ( x ) ) newlist . add ( x ) ; } Collections . reverse ( newlist ) ; int j = 0 ; for ( int i = 0 ; i < lis . size ( ) ; i ++ ) { if ( palindrome ( lis . get ( i ) ) ) { lis . set ( i , newlist . get ( j ) ) ; j = j + 1 ; } } for ( String x : lis ) System . out . print ( x + " ▁ " ) ; } public static void main ( String [ ] args ) { String sentence = " mom ▁ and ▁ dad ▁ went ▁ to ▁ eye ▁ hospital " ; printReverse ( sentence ) ; } }

Accumulator variables: ed, i, st, temp
Iterator variables: i, x
Class/struct names: GFG
Java program:
class GFG { static int minCount ( int A [ ] , int B [ ] , int N ) { int i = 0 ; for ( int j = 0 ; j < N ; j ++ ) { if ( A [ i ] == B [ j ] ) { i ++ ; } } return N - i ; } public static void main ( String [ ] args ) { int A [ ] = { 1 , 2 , 3 , 4 , 5 } ; int B [ ] = { 1 , 5 , 2 , 3 , 4 } ; int N = A . length ; System . out . println ( minCount ( A , B , N ) ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static boolean possible ( int A [ ] , int N , int mid , int K ) { int count = 0 ; for ( int i = 0 ; i < N ; i ++ ) { count += ( A [ i ] - 1 ) / mid ; } return count <= K ; } static int minimumMaximum ( int A [ ] , int N , int K ) { int lo = 1 ; Arrays . sort ( A ) ; int hi = A [ N - 1 ] ; int mid ; while ( lo < hi ) { mid = ( lo + hi ) / 2 ; if ( possible ( A , N , mid , K ) ) { hi = mid ; } else { lo = mid + 1 ; } } return hi ; } public static void main ( String [ ] args ) { int arr [ ] = { 2 , 4 , 8 , 2 } ; int K = 4 ; int N = arr . length ; System . out . println ( minimumMaximum ( arr , N , K ) ) ; } }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void maximumNumber ( int arr [ ] , int N , int K ) { int minimum = Arrays . stream ( arr ) . min ( ) . getAsInt ( ) ; int ans = minimum + K ; for ( int i = 0 ; i < N ; i ++ ) { if ( Math . abs ( arr [ i ] - ans ) > K ) { ans = - 1 ; break ; } } System . out . print ( ans ) ; } public static void main ( String args [ ] ) { int arr [ ] = { 1 , 2 , 5 } ; int K = 2 ; int N = arr . length ; maximumNumber ( arr , N , K ) ; } }

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