dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
import java . lang . Math ; import java . io . * ; class GFG { static boolean checkPerfectSquare ( double n ) { double d = Math . sqrt ( n ) ; if ( d * d == n ) return true ; return false ; } static int largestPerfectSquareNumber ( int a [ ] , double n ) { int maxi = - 1 ; for ( int i = 0 ; i < n ; i ++ ) { if ( checkPerfectSquare ( a [ i ] ) ) maxi = Math . max ( a [ i ] , maxi ) ; } return maxi ; } public static void main ( String [ ] args ) { int [ ] a = { 16 , 20 , 25 , 2 , 3 , 10 } ; double n = a . length ; System . out . println ( largestPerfectSquareNumber ( a , n ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void convert ( int n , int a [ ] ) { int z = a [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) { if ( a [ i ] > z ) z = a [ i ] ; } z = z + 1 ; int ff [ ] = new int [ z ] ; for ( int i = 0 ; i < n ; i ++ ) { ff [ a [ i ] ] += 1 ; } int cc = 0 ; for ( int i = 0 ; i < z ; i ++ ) { cc += ( ff [ i ] / 4 ) ; ff [ i ] = ff [ i ] % 4 ; } int vv = 0 ; for ( int i = 0 ; i < z ; i ++ ) { if ( ff [ i ] >= 2 ) vv += 1 ; } cc += ( vv / 2 ) ; System . out . println ( cc ) ; } public static void main ( String [ ] args ) { int n = 4 ; int a [ ] = { 1 , 2 , 1 , 2 } ; convert ( n , a ) ; } }

Index/key variables: i, z
Accumulator variables: cc, i, vv
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; public class ACE { static int gcd ( int a , int b ) { return b == 0 ? a : gcd ( b , a % b ) ; } static int find_LCM ( int x , int y ) { return ( x * y ) / gcd ( x , y ) ; } static int CountPairs ( int n , int m , int A , int B ) { int cnt = 0 ; int lcm = find_LCM ( A , B ) ; for ( int i = 1 ; i <= n ; i ++ ) cnt += ( m + ( i % lcm ) ) / lcm ; return cnt ; } public static void main ( String [ ] args ) { int n = 60 , m = 90 , A = 5 , B = 10 ; System . out . println ( CountPairs ( n , m , A , B ) ) ; } }

Accumulator variables: cnt, i
Iterator variables: i
Class/struct names: ACE
Java program:
import java . util . * ; class Node { static void sortArr ( int arr [ ] , int n , int min , int max ) { int m = max - min + 1 ; int [ ] c = new int [ m ] ; for ( int i = 0 ; i < n ; i ++ ) { c [ arr [ i ] - min ] ++ ; } for ( int i = 0 ; i < m ; i ++ ) { for ( int j = 0 ; j < c [ i ] ; j ++ ) { System . out . print ( ( i + min ) + " ▁ " ) ; } } } public static void main ( String [ ] args ) { int arr [ ] = { 10 , 10 , 1 , 4 , 4 , 100 , 0 } ; int min = 0 , max = 100 ; int n = arr . length ; sortArr ( arr , n , min , max ) ; } }

Index/key variables: i, m
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: Node
Java program:
import java . math . BigDecimal ; class GFG { public static boolean isPossible ( double D , int arr [ ] , int N , int K ) { int used = 0 ; for ( int i = 0 ; i < N - 1 ; ++ i ) { used += ( int ) ( ( arr [ i + 1 ] - arr [ i ] ) / D ) ; } return used <= K ; } public static double minMaxDist ( int stations [ ] , int N , int K ) { double low = 0 , high = 1e8 ; while ( high - low > 1e-6 ) { double mid = ( low + high ) / 2.0 ; if ( isPossible ( mid , stations , N , K ) ) { high = mid ; } else { low = mid ; } } return low ; } public static void main ( String args [ ] ) { int arr [ ] = { 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 } ; int K = 9 ; int N = arr . length ; System . out . printf ( " % .1f " , minMaxDist ( arr , N , K ) ) ; } }

Index/key variables: i
Accumulator variables: used
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void findMissingBinaryString ( String [ ] nums , int N ) { HashSet < String > s = new HashSet < String > ( ) ; int counter = 0 ; for ( String str : nums ) { s . add ( str ) ; } int total = ( int ) Math . pow ( 2 , N ) ; String ans = " " ; for ( int i = 0 ; i < total ; i ++ ) { String num = " " ; for ( int j = N - 1 ; j >= 0 ; j -- ) { if ( ( i & ( 1 << j ) ) > 0 ) { num += '1' ; } else { num += '0' ; } } if ( s . contains ( num ) ) { counter ++ ; continue ; } else { System . out . print ( num + " , ▁ " ) ; } } if ( counter == total ) { System . out . print ( " - 1" ) ; } } public static void main ( String [ ] args ) { int N = 3 ; String [ ] arr = { "101" , "111" , "001" , "011" , "100" , "110" } ; findMissingBinaryString ( arr , N ) ; } }

Accumulator variables: counter, i, j, num
Iterator variables: i, j, str
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static class pair { int first , second ; public pair ( int first , int second ) { this . first = first ; this . second = second ; } } static int n = 6 ; static int m = 6 ; static int dx [ ] = { 0 , 1 , - 1 , 0 } ; static int dy [ ] = { 1 , 0 , 0 , - 1 } ; static int [ ] [ ] visited = new int [ n ] [ m ] ; static int [ ] [ ] result = new int [ n ] [ m ] ; static int COUNT ; static boolean is_valid ( int x , int y , int matrix [ ] [ ] ) { if ( x < n && y < m && x >= 0 && y >= 0 ) { if ( visited [ x ] [ y ] == 0 && matrix [ x ] [ y ] == 1 ) return true ; else return false ; } else return false ; } static HashMap < Integer , Integer > mp = new HashMap < Integer , Integer > ( ) ; static void findComponentSize ( int matrix [ ] [ ] ) { for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { if ( visited [ i ] [ j ] == 0 && matrix [ i ] [ j ] == 1 ) { COUNT = 0 ; Queue < pair > q = new LinkedList < > ( ) ; q . add ( new pair ( i , j ) ) ; visited [ i ] [ j ] = 1 ; while ( ! q . isEmpty ( ) ) { pair p = q . peek ( ) ; q . remove ( ) ; int x = p . first , y = p . second ; COUNT ++ ; for ( int k = 0 ; k < 4 ; k ++ ) { int newX = x + dx [ k ] ; int newY = y + dy [ k ] ; if ( is_valid ( newX , newY , matrix ) ) { q . add ( new pair ( newX , newY ) ) ; visited [ newX ] [ newY ] = 1 ; } } } if ( mp . containsKey ( COUNT ) ) { mp . put ( COUNT , mp . get ( COUNT ) + 1 ) ; } else { mp . put ( COUNT , 1 ) ; } } } } } public static void main ( String [ ] args ) { int matrix [ ] [ ] = { { 1 , 1 , 1 , 1 , 1 , 1 } , { 1 , 1 , 0 , 0 , 0 , 0 } , { 0 , 0 , 0 , 1 , 1 , 1 } , { 0 , 0 , 0 , 1 , 1 , 1 } , { 0 , 0 , 1 , 0 , 0 , 0 } , { 1 , 0 , 0 , 0 , 0 , 0 } } ; int queries [ ] = { 6 , 1 , 8 , 2 } ; int N = queries . length ; findComponentSize ( matrix ) ; for ( int i = 0 ; i < N ; i ++ ) System . out . print ( ( mp . get ( queries [ i ] ) != null ? mp . get ( queries [ i ] ) : 0 ) + " ▁ " ) ; } }

Index/key variables: i, j, k, m, n, newX, newY, x, y
Accumulator variables: COUNT, i, j, k
Iterator variables: i, j, k
Class/struct names: GFG, pair
Java program:
import java . io . * ; class GFG { static boolean check ( int a [ ] , int b [ ] , int k , int x ) { int sum = 0 ; for ( int i = 0 ; i < a . length ; i ++ ) { sum = sum + ( int ) Math . pow ( Math . max ( a [ i ] - x , 0 ) , b [ i ] ) ; } if ( sum <= k ) return true ; else return false ; } static int findMin ( int a [ ] , int b [ ] , int n , int k ) { int l = 0 , u = ( int ) 1e9 ; while ( l < u ) { int m = ( l + u ) / 2 ; if ( check ( a , b , k , m ) ) u = m ; else l = m + 1 ; } return l ; } public static void main ( String [ ] args ) { int n = 5 ; int k = 12 ; int a [ ] = { 2 , 1 , 4 , 3 , 5 } ; int b [ ] = { 4 , 3 , 2 , 3 , 1 } ; System . out . println ( findMin ( a , b , n , k ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int getPairsCount ( int [ ] arr , int n ) { int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = arr [ i ] - ( i % arr [ i ] ) ; j < n ; j += arr [ i ] ) { if ( i < j && ( arr [ i ] * arr [ j ] ) == Math . abs ( i - j ) ) { count ++ ; } } } return count ; } public static void main ( String args [ ] ) { int [ ] arr = { 1 , 1 , 2 , 4 } ; int N = arr . length ; System . out . print ( getPairsCount ( 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 { public static void mostFrequent ( int [ ] arr , int N ) { int [ ] ans = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { int [ ] count = new int [ N ] ; int best = 1 ; for ( int j = i ; j < N ; j ++ ) { count [ arr [ j ] - 1 ] ++ ; if ( best > 0 ) { if ( ( count [ arr [ j ] - 1 ] > count [ best - 1 ] ) || ( count [ arr [ j ] - 1 ] == count [ best - 1 ] && arr [ j ] < best ) ) { best = arr [ j ] ; } ans [ best - 1 ] ++ ; } } } for ( int i = 0 ; i < N ; i ++ ) System . out . print ( ans [ i ] + " ▁ " ) ; } public static void main ( String [ ] args ) { int [ ] arr = { 2 , 1 , 2 , 3 } ; int N = arr . length ; mostFrequent ( arr , N ) ; } }

Index/key variables: N, i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . HashMap ; import java . io . * ; class GFG { static int log2 ( int N ) { int result = ( int ) ( Math . log ( N ) / Math . log ( 2 ) ) ; return result ; } static int countElement ( int arr [ ] , int N ) { int count = 0 ; HashMap < Integer , Integer > m = new HashMap < > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { if ( m . containsKey ( arr [ i ] ) ) { m . put ( arr [ i ] , m . get ( arr [ i ] ) + 1 ) ; } else { m . put ( arr [ i ] , 1 ) ; } } for ( int i = 0 ; i < N ; i ++ ) { int lg = log2 ( arr [ i ] ) ; int p = ( int ) Math . pow ( 2 , lg ) ; if ( m . containsKey ( p ) ) { count ++ ; } } return count ; } public static void main ( String [ ] args ) { int arr [ ] = { 3 , 4 , 6 , 9 } ; int N = arr . length ; System . out . println ( countElement ( arr , N ) ) ; } }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int lower_bound ( int [ ] a , int low , int high , long element ) { while ( low < high ) { int middle = low + ( high - low ) / 2 ; if ( element > a [ middle ] ) low = middle + 1 ; else high = middle ; } return low ; } static int maximumIntersections ( int [ ] [ ] arr , int N ) { int count = 0 ; int [ ] L = new int [ N ] ; int [ ] R = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { L [ i ] = arr [ i ] [ 0 ] ; R [ i ] = arr [ i ] [ 1 ] ; } Arrays . sort ( L ) ; Arrays . sort ( R ) ; for ( int i = 0 ; i < N ; i ++ ) { int l = arr [ i ] [ 0 ] ; int r = arr [ i ] [ 1 ] ; int x = lower_bound ( L , 0 , N , l ) ; int y = N - lower_bound ( R , 0 , N , r + 1 ) ; int cnt = x + y ; cnt = N - cnt - 1 ; count = Math . max ( count , cnt ) ; } return count ; } public static void main ( String [ ] args ) { int arr [ ] [ ] = { { 1 , 6 } , { 5 , 5 } , { 2 , 3 } } ; int N = arr . length ; System . out . println ( maximumIntersections ( arr , N ) ) ; } }

Index/key variables: N, i, middle
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static Node head1 = null ; static Node head2 = null ; static class Node { int data ; Node next ; Node ( int x ) { data = x ; next = null ; } } static Node intersectingNode ( Node headA , Node headB ) { Node a = headA ; while ( a != null ) { a . data *= - 1 ; a = a . next ; } Node b = headB ; while ( b != null ) { if ( b . data < 0 ) break ; b = b . next ; } return b ; } static void formLinkList ( ) { head1 = new Node ( 3 ) ; head1 . next = new Node ( 6 ) ; head1 . next . next = new Node ( 9 ) ; head1 . next . next . next = new Node ( 15 ) ; head1 . next . next . next . next = new Node ( 30 ) ; head2 = new Node ( 10 ) ; head2 . next = head1 . next . next . next ; return ; } public static void main ( String [ ] args ) { formLinkList ( ) ; System . out . println ( Math . abs ( intersectingNode ( head1 , head2 ) . data ) ) ; } }

Accumulator variables: data
Class/struct names: GFG, Node
Java program:
import java . util . * ; class GFG { static class TreeNode { public int val ; public TreeNode left , right ; } ; static TreeNode newNode ( int v ) { TreeNode temp = new TreeNode ( ) ; temp . val = v ; temp . left = temp . right = null ; return temp ; } static boolean isInc ( TreeNode root ) { Queue < TreeNode > que = new LinkedList < > ( ) ; que . add ( root ) ; while ( true ) { int len = que . size ( ) ; if ( len == 0 ) break ; TreeNode pre = que . peek ( ) ; while ( len > 0 ) { TreeNode temp = que . peek ( ) ; que . poll ( ) ; if ( pre . val > temp . val ) return false ; pre = temp ; if ( temp . left != null ) que . add ( temp . left ) ; if ( temp . right != null ) que . add ( temp . right ) ; len -= 1 ; } } return true ; } static void levelOrder ( TreeNode root ) { Queue < TreeNode > que = new LinkedList < > ( ) ; que . add ( root ) ; while ( true ) { int len = que . size ( ) ; if ( len == 0 ) break ; while ( len > 0 ) { TreeNode temp = que . peek ( ) ; que . poll ( ) ; System . out . print ( temp . val + " ▁ " ) ; if ( temp . left != null ) que . add ( temp . left ) ; if ( temp . right != null ) que . add ( temp . right ) ; len -= 1 ; } System . out . println ( ) ; } System . out . println ( ) ; } static void makeInc ( TreeNode root ) { Queue < TreeNode > que = new LinkedList < > ( ) ; que . add ( root ) ; while ( true ) { int len = que . size ( ) ; if ( len == 0 ) break ; int prev = - 1 ; while ( len > 0 ) { TreeNode temp = que . peek ( ) ; que . poll ( ) ; int optEle = temp . val ; String strEle = String . valueOf ( optEle ) ; boolean flag = true ; int yy = strEle . length ( ) ; for ( int idx = 0 ; idx < strEle . length ( ) ; idx ++ ) { String s1 = strEle . substring ( idx , yy ) ; String s2 = strEle . substring ( 0 , idx ) ; String s = s1 + s2 ; int ls = Integer . valueOf ( s ) ; if ( ls >= prev && flag ) { optEle = ls ; flag = false ; } if ( ls >= prev ) optEle = Math . min ( optEle , ls ) ; } temp . val = optEle ; prev = temp . val ; if ( temp . left != null ) que . add ( temp . left ) ; if ( temp . right != null ) que . add ( temp . right ) ; len -= 1 ; } } if ( isInc ( root ) == true ) levelOrder ( root ) ; else System . out . print ( - 1 ) ; } public static void main ( String [ ] args ) { TreeNode root = newNode ( 341 ) ; root . left = newNode ( 241 ) ; root . right = newNode ( 123 ) ; root . left . left = newNode ( 324 ) ; root . left . right = newNode ( 235 ) ; root . right . right = newNode ( 161 ) ; makeInc ( root ) ; } }

Accumulator variables: idx, len
Iterator variables: idx
Boolean variables: flag
Class/struct names: GFG, TreeNode
Java program:
import java . util . LinkedList ; import java . util . Queue ; import java . util . Stack ; class Node { int data ; Node left , right ; Node ( int item ) { data = item ; left = right ; } } class BinaryTree { Node root ; void reverseLevelOrder ( Node node ) { Stack < Node > S = new Stack ( ) ; Queue < Node > Q = new LinkedList ( ) ; Q . add ( node ) ; while ( Q . isEmpty ( ) == false ) { node = Q . peek ( ) ; Q . remove ( ) ; S . push ( node ) ; if ( node . right != null ) Q . add ( node . right ) ; if ( node . left != null ) Q . add ( node . left ) ; } while ( S . empty ( ) == false ) { node = S . peek ( ) ; System . out . print ( node . data + " ▁ " ) ; S . pop ( ) ; } } public static void main ( String args [ ] ) { BinaryTree tree = new BinaryTree ( ) ; tree . root = new Node ( 1 ) ; tree . root . left = new Node ( 2 ) ; tree . root . right = new Node ( 3 ) ; tree . root . left . left = new Node ( 4 ) ; tree . root . left . right = new Node ( 5 ) ; tree . root . right . left = new Node ( 6 ) ; tree . root . right . right = new Node ( 7 ) ; System . out . println ( " Level ▁ Order ▁ traversal ▁ of ▁ binary ▁ tree ▁ is ▁ : " ) ; tree . reverseLevelOrder ( tree . root ) ; } }

Class/struct names: BinaryTree, Node
Java program:
import java . io . * ; import java . lang . * ; import java . util . * ; class GFG { static void removeDuplicateCharacters ( String arr [ ] ) { HashSet < Character > cset = new HashSet < > ( ) ; int n = arr . length ; ArrayList < String > out = new ArrayList < > ( ) ; for ( String str : arr ) { String out_curr = " " ; for ( char ch : str . toCharArray ( ) ) { if ( cset . contains ( ch ) ) continue ; out_curr += ch ; cset . add ( ch ) ; } if ( out_curr . length ( ) != 0 ) out . add ( out_curr ) ; } for ( int i = 0 ; i < out . size ( ) ; i ++ ) { System . out . print ( out . get ( i ) + " ▁ " ) ; } } public static void main ( String [ ] args ) { String arr [ ] = { " Geeks " , " For " , " Geeks " , " Post " } ; removeDuplicateCharacters ( arr ) ; } }

Accumulator variables: i, out_curr
Iterator variables: ch, i, str
Class/struct names: GFG
Java program:
import java . io . * ; import java . lang . * ; 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 primeFactorSum ( int arr [ ] , int n , int k ) { int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( k % arr [ i ] == 0 && isPrime ( arr [ i ] ) ) { sum = sum + arr [ i ] ; } } System . out . println ( sum ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 3 , 5 , 6 , 7 , 15 } ; int N = arr . length ; int K = 35 ; primeFactorSum ( arr , N , K ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int minOperations ( int nums [ ] , int x ) { int sum = 0 ; for ( int i = 0 ; i < x ; i ++ ) sum += nums [ i ] ; if ( sum < x ) return - 1 ; int ans = Integer . MAX_VALUE ; int l = nums . length - 1 , r = nums . length ; x -= sum ; while ( l >= 0 ) { if ( x <= 0 ) { x += nums [ l ] ; l -= 1 ; } if ( x > 0 ) { r -= 1 ; x -= nums [ r ] ; } if ( x == 0 ) { ans = Math . min ( ans , ( l + 1 ) + ( nums . length - r ) ) ; } } if ( ans < Integer . MAX_VALUE ) return ans ; else return - 1 ; } public static void main ( String [ ] args ) { int [ ] nums = { 1 , 1 , 4 , 2 , 3 } ; int x = 5 ; System . out . println ( minOperations ( nums , x ) ) ; } }

Index/key variables: i, l, r
Accumulator variables: i, l, r, sum, x
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . lang . * ; import java . util . * ; class GFG { static int MAX = ( int ) ( 1e5 ) ; static class Key { int arr [ ] ; Key ( int arr [ ] ) { this . arr = arr ; } @ Override public int hashCode ( ) { return 31 + Arrays . hashCode ( arr ) ; } @ Override public boolean equals ( Object obj ) { if ( this == obj ) return true ; if ( obj == null || ( getClass ( ) != obj . getClass ( ) ) ) return false ; Key other = ( Key ) obj ; if ( ! Arrays . equals ( arr , other . arr ) ) return false ; return true ; } } static void primeFactors ( int v [ ] , int n ) { for ( int i = 2 ; i * i <= n ; i ++ ) { while ( n % i == 0 ) { v [ i ] ++ ; v [ i ] %= 3 ; n /= i ; } } if ( n != 1 ) { v [ n ] ++ ; v [ n ] %= 3 ; } } static void countSubarrays ( int arr [ ] , int n ) { int ans = 0 ; int v [ ] = new int [ MAX ] ; HashMap < Key , Integer > mp = new HashMap < > ( ) ; mp . put ( new Key ( v ) , 1 ) ; for ( int i = 0 ; i < n ; i ++ ) { primeFactors ( v , arr [ i ] ) ; ans += mp . getOrDefault ( new Key ( v ) , 0 ) ; Key vv = new Key ( v ) ; mp . put ( vv , mp . getOrDefault ( vv , 0 ) + 1 ) ; } System . out . println ( ans ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 8 , 4 , 2 } ; int N = arr . length ; countSubarrays ( arr , N ) ; } }

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

Index/key variables: i
Accumulator variables: total_odd
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; public class Main { static Boolean checkGroup ( Vector < Integer > arr ) { if ( arr . size ( ) <= 2 ) return true ; int corner = arr . get ( 0 ) + arr . get ( arr . size ( ) - 1 ) ; int xorSum = 0 ; for ( int i = 0 ; i < arr . size ( ) - 1 ; i ++ ) xorSum += ( arr . get ( i ) ^ arr . get ( i + 1 ) ) ; if ( corner == 0 ) if ( xorSum > 2 ) return false ; else if ( corner == 1 ) if ( xorSum > 1 ) return false ; else if ( xorSum > 0 ) return false ; return true ; } static Boolean isInGroupUtil ( int [ ] [ ] mat ) { for ( int i = 0 ; i < mat . length ; i ++ ) { Vector < Integer > arr = new Vector < Integer > ( ) ; for ( int j = 0 ; j < mat [ i ] . length ; j ++ ) { arr . add ( mat [ i ] [ j ] ) ; } if ( ! checkGroup ( arr ) ) return false ; } return true ; } static void isInGroup ( int [ ] [ ] mat ) { Boolean ans = isInGroupUtil ( mat ) ; if ( ans ) System . out . print ( " Yes " ) ; else System . out . print ( " No " ) ; } public static void main ( String [ ] args ) { int [ ] [ ] mat = { { 0 , 1 , 1 , 0 } , { 1 , 1 , 0 , 0 } , { 0 , 0 , 0 , 1 } , { 1 , 1 , 1 , 0 } } ; isInGroup ( mat ) ; } }

Index/key variables: i, j
Accumulator variables: i, j, xorSum
Iterator variables: i, j
Class/struct names: Main
Java program:
import java . io . * ; import java . util . * ; class GFG { static int productOfDigits ( int N ) { int product = 1 ; while ( N != 0 ) { product = product * ( N % 10 ) ; N = N / 10 ; } return product ; } static void productOfDigitsK ( int N , int K ) { int flag = 0 ; for ( int i = 1 ; i <= N ; ++ i ) { if ( K == productOfDigits ( i ) ) { System . out . print ( i + " ▁ " ) ; flag = 1 ; } } if ( flag == 0 ) System . out . println ( - 1 ) ; } public static void main ( String [ ] args ) { int N = 500 , K = 10 ; productOfDigitsK ( N , K ) ; } }

Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void minimiseDifference ( int [ ] arr , int K ) { int N = arr . length ; int [ ] maxSuffix = new int [ N + 1 ] ; int [ ] minSuffix = new int [ N + 1 ] ; maxSuffix [ N ] = - 1000000000 ; minSuffix [ N ] = 1000000000 ; maxSuffix [ N - 1 ] = arr [ N - 1 ] ; minSuffix [ N - 1 ] = arr [ N - 1 ] ; for ( int i = N - 2 ; i >= 0 ; -- i ) { maxSuffix [ i ] = Math . max ( maxSuffix [ i + 1 ] , arr [ i ] ) ; minSuffix [ i ] = Math . min ( minSuffix [ i + 1 ] , arr [ i ] ) ; } int maxPrefix = arr [ 0 ] ; int minPrefix = arr [ 0 ] ; int minDiff = maxSuffix [ K ] - minSuffix [ K ] ; for ( int i = 1 ; i < N ; ++ i ) { if ( i + K <= N ) { int maximum = Math . max ( maxSuffix [ i + K ] , maxPrefix ) ; int minimum = Math . min ( minSuffix [ i + K ] , minPrefix ) ; minDiff = Math . min ( minDiff , maximum - minimum ) ; } maxPrefix = Math . max ( maxPrefix , arr [ i ] ) ; minPrefix = Math . min ( minPrefix , arr [ i ] ) ; } System . out . print ( minDiff ) ; } public static void main ( String [ ] args ) { int [ ] arr = { 4 , 5 , 8 , 9 , 1 , 2 } ; int K = 2 ; minimiseDifference ( arr , K ) ; } }

Index/key variables: K, N, i
Iterator variables: i
Class/struct names: GFG