dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
import java . util . * ; class GFG { static boolean isPrime ( int n ) { if ( n <= 1 ) return false ; if ( n <= 3 ) return true ; if ( n % 2 == 0 n % 3 == 0 ) return false ; for ( int i = 5 ; i * i <= n ; i = i + 6 ) { if ( n % i == 0 || n % ( i + 2 ) == 0 ) { return false ; } } return true ; } static void sumOfPrimeSquare ( int n ) { int i = 0 ; ArrayList < Integer > squares = new ArrayList < Integer > ( ) ; while ( i * i < n ) { squares . add ( i * i ) ; i ++ ; } boolean flag = false ; for ( i = 0 ; i < squares . size ( ) ; i ++ ) { int difference = n - squares . get ( i ) ; if ( isPrime ( difference ) ) { flag = true ; break ; } } if ( flag ) { System . out . print ( " Yes " ) ; } else System . out . print ( " No " ) ; } public static void main ( String [ ] args ) { int N = 27 ; sumOfPrimeSquare ( N ) ; } }

Accumulator variables: i
Iterator variables: i
Boolean variables: flag
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void SieveOfEratosthenes ( boolean prime [ ] , int n ) { prime [ 0 ] = false ; prime [ 1 ] = false ; for ( int p = 2 ; p * p <= n ; p ++ ) { if ( prime [ p ] == true ) { for ( int i = p * p ; i <= n ; i += p ) { prime [ i ] = false ; } } } } static void sumOfPrimeSquare ( int n ) { boolean flag = false ; boolean [ ] prime = new boolean [ n + 1 ] ; for ( int i = 0 ; i < prime . length ; i ++ ) prime [ i ] = true ; SieveOfEratosthenes ( prime , n ) ; for ( int i = 0 ; i <= n ; i ++ ) { if ( ! prime [ i ] ) continue ; int dif = n - i ; if ( Math . ceil ( ( double ) Math . sqrt ( dif ) ) == Math . floor ( ( double ) Math . sqrt ( dif ) ) ) { flag = true ; break ; } } if ( flag ) { System . out . print ( " Yes " ) ; } else System . out . print ( " No " ) ; } public static void main ( String [ ] args ) { int N = 27 ; sumOfPrimeSquare ( N ) ; } }

Index/key variables: i, p
Accumulator variables: i, p
Iterator variables: i, p
Boolean variables: flag
Class/struct names: GFG
Java program:
import java . io . * ; import java . lang . * ; import java . util . * ; class GFG { static boolean check ( int arr [ ] , int M , int K , int ind ) { for ( int i = 0 ; i < M ; i ++ ) { for ( int j = 1 ; j < K ; j ++ ) { if ( arr [ ind + i ] != arr [ ind + i + j * M ] ) { return false ; } } } return true ; } static boolean SubarrayRepeatsKorMore ( int arr [ ] , int N , int M , int K ) { for ( int ind = 0 ; ind <= N - M * K ; ind ++ ) { if ( check ( arr , M , K , ind ) ) { return true ; } } return false ; } public static void main ( String [ ] args ) { int arr [ ] = { 2 , 1 , 2 , 1 , 1 , 1 , 3 } ; int M = 2 , K = 2 ; int N = arr . length ; if ( SubarrayRepeatsKorMore ( arr , N , M , K ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } }

Accumulator variables: i, ind, j
Iterator variables: i, ind, j
Class/struct names: GFG
Java program:
import java . io . * ; import java . lang . * ; import java . util . * ; class GFG { static boolean checkExists ( int arr [ ] , int N , int M , int K ) { int count = 0 ; for ( int i = 0 ; i < N - M ; i ++ ) { if ( arr [ i ] == arr [ i + M ] ) count ++ ; else count = 0 ; if ( count == M * ( K - 1 ) ) return true ; } return false ; } public static void main ( String [ ] args ) { int arr [ ] = { 2 , 1 , 2 , 1 , 1 , 1 , 3 } ; int M = 2 , K = 2 ; int N = arr . length ; if ( checkExists ( arr , N , M , K ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int CommonDigits ( int N , int M ) { int count = 0 ; int freq1 [ ] = new int [ 10 ] ; int freq2 [ ] = new int [ 10 ] ; while ( N > 0 ) { freq1 [ N % 10 ] ++ ; N = N / 10 ; } while ( M > 0 ) { freq2 [ M % 10 ] ++ ; M = M / 10 ; } for ( int i = 0 ; i < 10 ; i ++ ) { if ( freq1 [ i ] > 0 & freq2 [ i ] > 0 ) { count ++ ; } } return count ; } public static void main ( String [ ] args ) { int N = 748294 ; int M = 34298156 ; System . out . print ( CommonDigits ( N , M ) ) ; } }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . lang . * ; import java . util . * ; class GFG { static void minimumNumber ( int K , int X ) { if ( K > X ) { System . out . println ( " - 1" ) ; return ; } int ans = 0 ; int sum = 0 ; for ( int i = K ; i <= X ; i ++ ) { sum += i ; if ( sum >= X ) { ans = i ; break ; } } System . out . println ( ans ) ; } public static void main ( String [ ] args ) { int K = 5 , X = 13 ; minimumNumber ( K , X ) ; } }

Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . lang . * ; import java . util . * ; class GFG { static boolean isGreaterEqual ( int N , int K , int X ) { return ( ( N * 1L * ( N + 1 ) / 2 ) - ( ( K - 1 ) * 1L * K / 2 ) ) >= X ; } static void minimumNumber ( int K , int X ) { if ( K > X ) { System . out . println ( " - 1" ) ; return ; } int low = K , high = X , res = - 1 ; while ( low <= high ) { int mid = low + ( high - low ) / 2 ; if ( isGreaterEqual ( mid , K , X ) ) { res = mid ; high = mid - 1 ; } else low = mid + 1 ; } System . out . println ( res ) ; } public static void main ( String [ ] args ) { int K = 5 , X = 13 ; minimumNumber ( K , X ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int CountPairs ( int [ ] arr , int n ) { int count = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { if ( ( i * j ) == ( arr [ i ] * arr [ j ] ) ) count ++ ; } } return count ; } public static void main ( String [ ] args ) { int [ ] arr = { 1 , 0 , 3 , 2 , 6 } ; int N = arr . length ; System . out . println ( CountPairs ( arr , N ) ) ; } }

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 void maxRemainder ( int A [ ] , int N , int K ) { HashSet < Integer > even = new HashSet < > ( ) ; TreeSet < Integer > odd = new TreeSet < > ( ) ; for ( int num : A ) { if ( num % 2 == 0 ) even . add ( num % K ) ; else odd . add ( num % K ) ; } int max_rem = 0 ; for ( int x : even ) { int y = K - 1 - x ; if ( odd . floor ( y ) != null ) max_rem = Math . max ( max_rem , x + odd . floor ( y ) ) ; } System . out . print ( max_rem ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 3 , 2 , 4 , 11 , 6 , 7 } ; int N = arr . length ; int K = 7 ; maxRemainder ( arr , N , K ) ; } }

Iterator variables: num, x
Class/struct names: GFG
Java program:
import java . util . ArrayList ; class GFG { static int distance ; private static void dfs ( int src , ArrayList < ArrayList < Integer > > Adj , ArrayList < Boolean > visited , int level ) { visited . set ( src , true ) ; distance = Math . max ( distance , level ) ; for ( int child : Adj . get ( src ) ) { if ( ( child != src ) && ( visited . get ( child ) == false ) ) { dfs ( child , Adj , visited , level + 1 ) ; } } visited . set ( src , false ) ; } private static int maximumLength ( int [ ] [ ] mat , int v ) { distance = 0 ; int N = mat [ 0 ] . length ; ArrayList < Boolean > visited = new ArrayList < Boolean > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { visited . add ( false ) ; } ArrayList < ArrayList < Integer > > Adj = new ArrayList < ArrayList < Integer > > ( N ) ; for ( int i = 0 ; i < N ; i ++ ) { Adj . add ( new ArrayList < Integer > ( ) ) ; } int i , j ; for ( i = 0 ; i < mat [ 0 ] . length ; i ++ ) { for ( j = 0 ; j < mat . length ; j ++ ) { if ( mat [ i ] [ j ] == 1 ) { Adj . get ( i ) . add ( j ) ; } } } dfs ( v , Adj , visited , 0 ) ; return distance ; } public static void main ( String [ ] args ) { int [ ] [ ] mat = { { 0 , 1 , 0 , 0 } , { 1 , 0 , 1 , 1 } , { 0 , 1 , 0 , 0 } , { 0 , 1 , 0 , 0 } } ; int v = 2 ; System . out . print ( maximumLength ( mat , v ) ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: child, i, j
Class/struct names: GFG
Java program:
class GFG { static int findLength ( String s , char i , char j ) { char required = i ; int length = 0 ; for ( int k = 0 ; k < s . length ( ) ; k ++ ) { char curr = s . charAt ( k ) ; if ( curr == required ) { length += 1 ; if ( required == i ) required = j ; else required = i ; } } return length ; } static int minimumDeletions ( String S ) { int len = 0 ; int n = S . length ( ) ; for ( int i = 0 ; i < 26 ; i ++ ) { for ( int j = i + 1 ; j < 26 ; j ++ ) { int newLen = findLength ( S , ( char ) ( i + 97 ) , ( char ) ( j + 97 ) ) ; len = Math . max ( len , newLen ) ; } } return n - len ; } public static void main ( String [ ] args ) { String S = " adebbeeaebd " ; System . out . print ( minimumDeletions ( S ) ) ; } }

Accumulator variables: i, j, k, length
Iterator variables: i, j, k
Class/struct names: GFG
Java program:
import java . io . * ; import java . lang . * ; import java . util . * ; public class Main { static int inv ( int a , int m ) { int m0 = m , t , q ; int x0 = 0 , x1 = 1 ; if ( m == 1 ) return 0 ; while ( a > 1 ) { q = a / m ; t = m ; m = a % m ; a = t ; t = x0 ; x0 = x1 - q * x0 ; x1 = t ; } if ( x1 < 0 ) x1 += m0 ; return x1 ; } static int findMinX ( int A [ ] , int B [ ] , int N ) { int prod = 1 ; for ( int i = 0 ; i < N ; i ++ ) prod *= A [ i ] ; int result = 0 ; for ( int i = 0 ; i < N ; i ++ ) { int pp = prod / A [ i ] ; result += B [ i ] * inv ( pp , A [ i ] ) * pp ; } return result % prod ; } static int product ( int a [ ] ) { int ans = 1 ; for ( int i = 0 ; i < a . length ; i ++ ) { ans *= a [ i ] ; } return ans ; } public static void findSmallestInteger ( int A [ ] , int B [ ] , int P ) { int Y = findMinX ( A , B , A . length ) ; int M = product ( A ) ; int K = ( int ) Math . ceil ( ( ( double ) P - ( double ) Y ) / ( double ) M ) ; int X = Y + K * M ; System . out . println ( X ) ; } public static void main ( String [ ] args ) { int A [ ] = { 3 , 4 , 5 } ; int B [ ] = { 2 , 3 , 1 } ; int P = 72 ; findSmallestInteger ( A , B , P ) ; } }

Index/key variables: i
Accumulator variables: ans, i, prod, result, x1
Iterator variables: i
Class/struct names: Main
Java program:
import java . io . * ; import java . lang . * ; import java . util . * ; class GFG { static void minJumps ( int arr [ ] , int jump [ ] , int N ) { int jumps = 0 ; int temp [ ] = new int [ 1000 ] ; int vect [ ] [ ] = new int [ N ] [ 2 ] ; for ( int i = 0 ; i < N ; i ++ ) { vect [ i ] [ 0 ] = arr [ i ] ; vect [ i ] [ 1 ] = i + 1 ; } for ( int i = 0 ; i < N ; i ++ ) { temp [ arr [ i ] ] = jump [ i ] ; } Arrays . sort ( vect , ( a , b ) -> { if ( a [ 0 ] != b [ 0 ] ) return a [ 0 ] - b [ 0 ] ; return a [ 1 ] - b [ 1 ] ; } ) ; for ( int i = 1 ; i < N ; i ++ ) { while ( vect [ i ] [ 1 ] <= vect [ i - 1 ] [ 1 ] ) { vect [ i ] [ 0 ] = vect [ i ] [ 0 ] ; vect [ i ] [ 1 ] = vect [ i ] [ 1 ] + temp [ vect [ i ] [ 0 ] ] ; jumps ++ ; } } System . out . println ( jumps ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 3 , 2 , 1 } ; int jump [ ] = { 1 , 1 , 1 } ; int N = arr . length ; minJumps ( arr , jump , N ) ; } }

Index/key variables: N, i
Accumulator variables: i, jumps
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static void numberOfGates ( String s ) { int N = s . length ( ) ; int ans = 0 ; for ( int i = 0 ; i < ( int ) s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == ' . ' || s . charAt ( i ) == ' + ' || s . charAt ( i ) == '1' ) { ans ++ ; } } System . out . println ( ans ) ; } public static void main ( String [ ] args ) { String S = " ( 1 - A ) . B + C " ; numberOfGates ( S ) ; } }

Accumulator variables: ans, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . Arrays ; class GFG { static void findPairs ( int arr [ ] , int N ) { for ( int i = 0 ; i < N ; i ++ ) arr [ i ] = Math . abs ( arr [ i ] ) ; Arrays . sort ( arr ) ; int left = 0 ; int ans = 0 ; for ( int right = 0 ; right < N ; right ++ ) { while ( 2 * arr [ left ] < arr [ right ] ) left ++ ; ans += ( right - left ) ; } System . out . print ( ans ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 3 , 5 , 7 } ; int N = arr . length ; findPairs ( arr , N ) ; } }

Index/key variables: i, left, right
Accumulator variables: ans, i, left, right
Iterator variables: i, right
Class/struct names: GFG
Java program:
import java . io . * ; import java . lang . * ; import java . util . * ; class GFG { static int GetDiff ( int A [ ] , int N ) { int SuffMaxArr [ ] = new int [ N ] ; SuffMaxArr [ N - 1 ] = A [ N - 1 ] ; for ( int i = N - 2 ; i >= 0 ; -- i ) { SuffMaxArr [ i ] = Math . max ( SuffMaxArr [ i + 1 ] , A [ i + 1 ] ) ; } int MaximumSum = Integer . MIN_VALUE ; for ( int i = 0 ; i < N - 1 ; i ++ ) { if ( A [ i ] < SuffMaxArr [ i ] ) MaximumSum = Math . max ( MaximumSum , A [ i ] + SuffMaxArr [ i ] ) ; } int MinimumSum = Integer . MAX_VALUE ; int SuffMinArr [ ] = new int [ N ] ; SuffMinArr [ N - 1 ] = Integer . MAX_VALUE ; for ( int i = N - 2 ; i >= 0 ; -- i ) { SuffMinArr [ i ] = Math . min ( SuffMinArr [ i + 1 ] , A [ i + 1 ] ) ; } for ( int i = 0 ; i < N - 1 ; i ++ ) { if ( A [ i ] < SuffMinArr [ i ] ) { MinimumSum = Math . min ( MinimumSum , A [ i ] + SuffMinArr [ i ] ) ; } } return Math . abs ( MaximumSum - MinimumSum ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 2 , 4 , 1 , 3 , 7 , 5 , 6 } ; int N = arr . length ; System . out . println ( GetDiff ( arr , N ) ) ; } }

Index/key variables: N, i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . lang . * ; import java . util . * ; class GFG { static void minimumSwaps ( int arr [ ] , int N ) { int even = 0 , odd = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( arr [ i ] % 2 != i % 2 ) { if ( i % 2 == 0 ) { even ++ ; } else { odd ++ ; } } } if ( even != odd ) { System . out . println ( - 1 ) ; } else { System . out . println ( even ) ; } } public static void main ( String [ ] args ) { int arr [ ] = { 3 , 2 , 7 , 6 } ; int N = arr . length ; minimumSwaps ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: even, i, odd
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . lang . * ; import java . util . * ; class GFG { static int smallestSubstring ( String a ) { ArrayList < String > a1 = new ArrayList < > ( ) ; for ( int i = 0 ; i < a . length ( ) ; i ++ ) { for ( int j = i + 1 ; j <= a . length ( ) ; j ++ ) { if ( i != j ) a1 . add ( a . substring ( i , j ) ) ; } } TreeMap < String , Integer > a2 = new TreeMap < > ( ) ; for ( String s : a1 ) a2 . put ( s , a2 . getOrDefault ( s , 0 ) + 1 ) ; ArrayList < String > freshlist = new ArrayList < > ( ) ; for ( String s : a2 . keySet ( ) ) { if ( a2 . get ( s ) == 1 ) freshlist . add ( s ) ; } TreeMap < String , Integer > dictionary = new TreeMap < > ( ) ; for ( String s : freshlist ) { dictionary . put ( s , s . length ( ) ) ; } ArrayList < Integer > newlist = new ArrayList < > ( ) ; for ( String s : dictionary . keySet ( ) ) newlist . add ( dictionary . get ( s ) ) ; int ans = Integer . MAX_VALUE ; for ( int i : newlist ) ans = Math . min ( ans , i ) ; return ans == Integer . MAX_VALUE ? 0 : ans ; } public static void main ( String [ ] args ) { String S = " ababaabba " ; System . out . println ( smallestSubstring ( S ) ) ; } }

Accumulator variables: i, j
Iterator variables: i, j, s
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int mininsert ( int arr [ ] , int K , int N ) { int ans = 0 ; for ( int i = 0 ; i < N - 1 ; i ++ ) { int a = Math . min ( arr [ i ] , arr [ i + 1 ] ) ; int b = Math . max ( arr [ i ] , arr [ i + 1 ] ) ; while ( K * a < b ) { a *= K ; ans ++ ; } } return ans ; } public static void main ( String [ ] args ) { int arr [ ] = { 2 , 10 , 25 , 21 } ; int K = 2 ; int N = arr . length ; System . out . print ( mininsert ( arr , K , N ) ) ; } }

Index/key variables: i
Accumulator variables: a, ans, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { static int sumOfDigits ( String s ) { int curr = 0 ; int ret = 0 ; for ( char ch : s . toCharArray ( ) ) { if ( ch >= 48 && ch <= 57 ) { curr = curr * 10 + ch - '0' ; } else { ret += curr ; curr = 0 ; } } ret += curr ; return ret ; } public static void main ( String [ ] args ) { String S = "11aa32bbb5" ; System . out . print ( sumOfDigits ( S ) ) ; } }

Accumulator variables: ret
Iterator variables: ch
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void print_triplet ( int arr [ ] , int n ) { for ( int i = 1 ; i <= n - 2 ; i ++ ) { if ( arr [ i - 1 ] < arr [ i ] && arr [ i ] > arr [ i + 1 ] ) { System . out . print ( i - 1 + " ▁ " + i + " ▁ " + ( i + 1 ) ) ; return ; } } System . out . print ( - 1 ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 4 , 3 , 5 , 2 , 1 , 6 } ; int N = arr . length ; print_triplet ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { static void findConcatenatedNumbers ( int [ ] a , int [ ] b ) { boolean ans = true ; int n1 = a . length ; int n2 = b . length ; int cnt [ ] = new int [ 100000 ] ; for ( int i = 0 ; i < n1 ; i ++ ) { cnt [ a [ i ] ] = 1 ; } for ( int i = 0 ; i < n2 ; i ++ ) { int left = b [ i ] ; int right = 0 ; int mul = 1 ; while ( left > 9 ) { right += ( left % 10 ) * mul ; left /= 10 ; mul *= 10 ; if ( cnt [ left ] == 1 && cnt [ right ] == 1 ) { ans = false ; System . out . print ( b [ i ] + " ▁ " ) ; } } } if ( ans ) System . out . print ( " - 1" ) ; } public static void main ( String [ ] args ) { int [ ] a = { 2 , 34 , 4 , 5 } ; int [ ] b = { 26 , 24 , 345 , 4 , 22 } ; findConcatenatedNumbers ( a , b ) ; } }

Index/key variables: i, left, right
Accumulator variables: i, left, mul, right
Iterator variables: i
Boolean variables: ans
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static void evenproduct ( int arr [ ] , int length ) { int count = 0 ; for ( int i = 0 ; i < arr . length ; i ++ ) { int product = 1 ; for ( int j = i ; j < arr . length ; j ++ ) { product *= arr [ j ] ; if ( product % 2 == 0 ) ++ count ; } } System . out . println ( count ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 7 , 5 , 4 , 9 } ; int length = arr . length - 1 ; evenproduct ( arr , length ) ; } }

Index/key variables: j
Accumulator variables: i, j, product
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int ans = 0 ; static ArrayList < Integer > [ ] adj = new ArrayList [ ( int ) ( 1e5 ) + 1 ] ; static { for ( int i = 0 ; i < adj . length ; i ++ ) adj [ i ] = new ArrayList < > ( ) ; } static void dfsUtil ( int u , int par , int depth ) { for ( int it : adj [ u ] ) { if ( it != par ) { dfsUtil ( it , u , depth + 1 ) ; } } ans += depth ; } static void dfs ( int u , int par , int depth ) { dfsUtil ( u , par , depth ) ; System . out . print ( ans + "NEW_LINE"); } static void countPairs ( int [ ] [ ] edges ) { for ( int i = 0 ; i < edges . length ; i ++ ) { int u = edges [ i ] [ 0 ] ; int v = edges [ i ] [ 1 ] ; adj [ u ] . add ( v ) ; adj [ v ] . add ( u ) ; } dfs ( 1 , 1 , 1 ) ; } public static void main ( String [ ] args ) { int [ ] [ ] edges = { { 1 , 2 } , { 1 , 3 } , { 2 , 4 } } ; countPairs ( edges ) ; } }

Index/key variables: i, u, v
Accumulator variables: ans, i
Iterator variables: i, it
Class/struct names: GFG
Java program:
import java . util . ArrayList ; import java . util . LinkedList ; import java . util . Queue ; class GFG { static class TreeNode { int val ; TreeNode left , right ; public TreeNode ( int key ) { val = key ; left = right = null ; } } static int convertBinaryToDecimal ( ArrayList < Integer > arr ) { int ans = 0 ; for ( int i : arr ) ans = ( ans << 1 ) | i ; return ans ; } static void decimalEquilvalentAtEachLevel ( TreeNode root ) { int ans = 0 ; Queue < TreeNode > que = new LinkedList < > ( ) ; que . add ( root ) ; while ( true ) { int length = que . size ( ) ; if ( length == 0 ) break ; ArrayList < Integer > eachLvl = new ArrayList < > ( ) ; while ( length > 0 ) { TreeNode temp = que . poll ( ) ; eachLvl . add ( temp . val ) ; if ( temp . left != null ) que . add ( temp . left ) ; if ( temp . right != null ) que . add ( temp . right ) ; length -= 1 ; } ans += convertBinaryToDecimal ( eachLvl ) ; } System . out . println ( ans ) ; } public static void main ( String [ ] args ) { TreeNode root = new TreeNode ( 0 ) ; root . left = new TreeNode ( 1 ) ; root . right = new TreeNode ( 0 ) ; root . left . left = new TreeNode ( 0 ) ; root . left . right = new TreeNode ( 1 ) ; root . right . left = new TreeNode ( 1 ) ; root . right . right = new TreeNode ( 1 ) ; decimalEquilvalentAtEachLevel ( root ) ; } }

Accumulator variables: ans, length
Iterator variables: i
Class/struct names: GFG, TreeNode
Java program:
public class GFG { static void minimumOperations ( int [ ] arr , int N ) { int oddCnt = 0 , evenCnt = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( arr [ i ] % 2 == 0 ) { evenCnt ++ ; } else { oddCnt ++ ; } } System . out . print ( Math . min ( oddCnt , evenCnt ) ) ; } public static void main ( String args [ ] ) { int [ ] arr = { 4 , 1 , 2 } ; int N = arr . length ; minimumOperations ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: evenCnt, i, oddCnt
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int minIncr ( int [ ] arr , int n ) { int forEven = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( i % 2 == 1 ) { if ( ( arr [ i ] % 2 ) == 0 ) forEven += 1 ; } else { if ( arr [ i ] % 2 == 1 ) forEven += 1 ; } } return Math . min ( forEven , n - forEven ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 4 , 6 , 8 , 9 , 5 } ; int n = arr . length ; System . out . println ( minIncr ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: forEven, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void minOperations ( int [ ] arr , int N , int [ ] Q , int M ) { Map < Integer , Integer > m1 = new HashMap < Integer , Integer > ( ) ; Map < Integer , Integer > m2 = new HashMap < Integer , Integer > ( ) ; int front = 0 , rear = 0 ; for ( int i = 0 ; i < N ; i ++ ) { front += arr [ i ] ; m1 . put ( arr [ i ] , front ) ; } for ( int i = N - 1 ; i >= 0 ; i -- ) { rear += arr [ i ] ; m2 . put ( arr [ i ] , rear ) ; } for ( int i = 0 ; i < M ; i ++ ) { System . out . print ( Math . min ( m1 . get ( Q [ i ] ) , m2 . get ( Q [ i ] ) ) + " ▁ " ) ; } } public static void main ( String [ ] args ) { int [ ] arr = { 2 , 3 , 6 , 7 , 4 , 5 , 1 } ; int N = arr . length ; int [ ] Q = { 7 , 6 } ; int M = Q . length ; minOperations ( arr , N , Q , M ) ; } }

Index/key variables: i
Accumulator variables: front, i, rear
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { public static boolean checkAnagram ( String s1 , String s2 ) { int s2hash [ ] = new int [ 26 ] ; int s1hash [ ] = new int [ 26 ] ; int s1len = s1 . length ( ) ; int s2len = s2 . length ( ) ; if ( s1len > s2len ) return false ; int left = 0 , right = 0 ; while ( right < s1len ) { s1hash [ s1 . charAt ( right ) - ' a ' ] += 1 ; s2hash [ s2 . charAt ( right ) - ' a ' ] += 1 ; right ++ ; } right -= 1 ; while ( right < s2len ) { if ( Arrays . equals ( s1hash , s2hash ) ) return true ; right ++ ; if ( right != s2len ) s2hash [ s2 . charAt ( right ) - ' a ' ] += 1 ; s2hash [ s2 . charAt ( left ) - ' a ' ] -= 1 ; left ++ ; } return false ; } public static void main ( String [ ] args ) { String s1 = " ab " ; String s2 = " bbpobac " ; if ( checkAnagram ( s1 , s2 ) ) System . out . println ( " YES " ) ; else System . out . println ( " No " ) ; } }

Accumulator variables: left, right
Class/struct names: GFG