dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
import java . util . * ; class GFG { static int count_pairs ( int arr [ ] , int brr [ ] , int N , int M , int K ) { int i = 0 ; int j = 0 ; int cntPairs = 0 ; Arrays . sort ( arr ) ; Arrays . sort ( brr ) ; while ( i < N && j < M ) { if ( brr [ j ] - arr [ i ] > K ) { cntPairs += ( M - j ) ; i ++ ; } else { j ++ ; } } return cntPairs ; } public static void main ( String args [ ] ) { int arr [ ] = { 5 , 9 , 1 , 8 } ; int brr [ ] = { 10 , 12 , 7 , 4 , 2 , 3 } ; int K = 3 ; int N = arr . length ; int M = brr . length ; System . out . println ( count_pairs ( arr , brr , N , M , K ) ) ; } }

Index/key variables: i, j
Accumulator variables: cntPairs, i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void minHeapify ( int brr [ ] , int i , int M ) { int left = 2 * i + 1 ; int right = 2 * i + 2 ; int smallest = i ; if ( left < M && brr [ left ] < brr [ smallest ] ) { smallest = left ; } if ( right < M && brr [ right ] < brr [ smallest ] ) { smallest = right ; } if ( smallest != i ) { int temp = brr [ i ] ; brr [ i ] = brr [ smallest ] ; brr [ smallest ] = temp ; minHeapify ( brr , smallest , M ) ; } } static void merge ( int arr [ ] , int brr [ ] , int N , int M ) { for ( int i = 0 ; i < N ; ++ i ) { if ( arr [ i ] > brr [ 0 ] ) { int temp = arr [ i ] ; arr [ i ] = brr [ 0 ] ; brr [ 0 ] = temp ; minHeapify ( brr , 0 , M ) ; } } Arrays . sort ( brr ) ; } static void printArray ( int arr [ ] , int N ) { for ( int i = 0 ; i < N ; i ++ ) System . out . print ( arr [ i ] + " ▁ " ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 2 , 23 , 35 , 235 , 2335 } ; int brr [ ] = { 3 , 5 } ; int N = arr . length ; int M = brr . length ; merge ( arr , brr , N , M ) ; printArray ( arr , N ) ; printArray ( brr , M ) ; } }

Index/key variables: i, left, right, smallest
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void partition ( int arr [ ] , int N , int brr [ ] , int M , int Pivot ) { int l = N - 1 ; int r = 0 ; while ( l >= 0 && r < M ) { if ( arr [ l ] < Pivot ) l -- ; else if ( brr [ r ] > Pivot ) r ++ ; else { int t = arr [ l ] ; arr [ l ] = brr [ r ] ; brr [ r ] = t ; l -- ; r ++ ; } } } static void Merge ( int arr [ ] , int N , int brr [ ] , int M ) { int l = 0 ; int r = 0 ; int index = - 1 ; int Pivot = 0 ; while ( index < N && l < N && r < M ) { if ( arr [ l ] < brr [ r ] ) { Pivot = arr [ l ++ ] ; } else { Pivot = brr [ r ++ ] ; } index ++ ; } while ( index < N && l < N ) { Pivot = arr [ l ++ ] ; index ++ ; } while ( index < N && r < M ) { Pivot = brr [ r ++ ] ; index ++ ; } partition ( arr , N , brr , M , Pivot ) ; Arrays . sort ( arr ) ; Arrays . sort ( brr ) ; for ( int i = 0 ; i < N ; i ++ ) System . out . print ( arr [ i ] + " ▁ " ) ; for ( int i = 0 ; i < M ; i ++ ) System . out . print ( brr [ i ] + " ▁ " ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 5 , 9 } ; int brr [ ] = { 2 , 4 , 7 , 10 } ; int N = arr . length ; int M = brr . length ; Merge ( arr , N , brr , M ) ; } }

Index/key variables: i, l, r
Accumulator variables: i, index, l, r
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; import java . lang . * ; class GFG { static int rankLessThanK ( int [ ] arr , int k , int n ) { int rank = 1 ; int position = 1 ; Arrays . sort ( arr ) ; for ( int i = n - 1 ; i >= 0 ; i -- ) { if ( i == n - 1 arr [ i ] != arr [ i + 1 ] ) { rank = position ; if ( rank > k ) return position - 1 ; } position ++ ; } return n ; } public static void main ( String [ ] args ) { int arr [ ] = { 2 , 2 , 3 , 4 , 5 } ; int N = arr . length ; int K = 4 ; System . out . println ( rankLessThanK ( arr , K , N ) ) ; } }

Index/key variables: i
Accumulator variables: i, position
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { static void eraseSubdirectory ( ArrayList < String > dir ) { ArrayList < String > res = new ArrayList < String > ( ) ; Collections . sort ( dir ) ; res . add ( dir . get ( 0 ) ) ; System . out . print ( " { " + dir . get ( 0 ) + " , ▁ " ) ; for ( int i = 1 ; i < dir . size ( ) ; i ++ ) { String curr = dir . get ( i ) ; String prev = res . get ( res . size ( ) - 1 ) ; int l = prev . length ( ) ; if ( curr . length ( ) > l && curr . charAt ( l ) == ' / ' && prev . equals ( curr . substring ( 0 , l ) ) ) continue ; res . add ( curr ) ; System . out . print ( curr + " , ▁ " ) ; } System . out . print ( "}NEW_LINE"); } public static void main ( String [ ] args ) { ArrayList < String > dir = new ArrayList < String > ( Arrays . asList ( " / a " , " / a / j " , " / c / d / e " , " / c / d " , " / b " ) ) ; eraseSubdirectory ( dir ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { static int numberOfPairs ( int [ ] arr1 , int n , int [ ] arr2 , int m ) { PriorityQueue < Integer > pQueue = new PriorityQueue < Integer > ( new Comparator < Integer > ( ) { public int compare ( Integer lhs , Integer rhs ) { if ( lhs < rhs ) { return + 1 ; } if ( lhs . equals ( rhs ) ) { return 0 ; } return - 1 ; } } ) ; int i , j ; Arrays . sort ( arr1 ) ; for ( j = 0 ; j < m ; j ++ ) { pQueue . add ( arr2 [ j ] ) ; } int ans = 0 ; for ( i = n - 1 ; i >= 0 ; i -- ) { if ( pQueue . peek ( ) >= 2 * arr1 [ i ] ) { ans ++ ; pQueue . poll ( ) ; } } return ans ; } public static void main ( String [ ] args ) { int [ ] arr1 = { 3 , 1 , 2 } ; int [ ] arr2 = { 3 , 4 , 2 , 1 } ; int N = 3 ; int M = 4 ; System . out . println ( numberOfPairs ( arr1 , N , arr2 , M ) ) ; } }

Index/key variables: i, j
Accumulator variables: ans, i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void minCost ( int arr [ ] , int n ) { if ( n == 1 ) { System . out . print ( 0 + "NEW_LINE"); return ; } Arrays . sort ( arr ) ; float raised = 1 / ( float ) ( n - 1 ) ; float temp = ( float ) Math . pow ( arr [ n - 1 ] , raised ) ; int r = ( int ) ( temp ) + 1 ; int i , j , min_cost = Integer . MAX_VALUE ; int common_ratio = 1 ; for ( j = 1 ; j <= r ; j ++ ) { int curr_cost = 0 , prod = 1 ; for ( i = 0 ; i < n ; i ++ ) { curr_cost += Math . abs ( arr [ i ] - prod ) ; prod *= j ; if ( curr_cost >= min_cost ) break ; } if ( i == n ) { min_cost = Math . min ( min_cost , curr_cost ) ; common_ratio = j ; } } System . out . print ( min_cost + " ▁ " ) ; System . out . print ( common_ratio + " ▁ " ) ; } public static void main ( String [ ] args ) { int N = 6 ; int arr [ ] = { 1 , 11 , 4 , 27 , 15 , 33 } ; minCost ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: curr_cost, i, j, prod
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static final int maxN = 10 ; static void calculateFib ( int fib [ ] , int n ) { fib [ 0 ] = fib [ 1 ] = 1 ; for ( int x = 2 ; x < n ; x ++ ) { fib [ x ] = fib [ x - 1 ] + fib [ x - 2 ] ; } } static int find_mth_bit ( int n , int m , int fib [ ] ) { if ( n <= 1 ) { return n ; } int len_left = fib [ n - 2 ] ; int len_right = fib [ n - 1 ] ; if ( m <= len_left ) { return find_mth_bit ( n - 2 , len_left + 1 - m , fib ) ; } else { return find_mth_bit ( n - 1 , len_right + 1 - ( m - len_left ) , fib ) ; } } static void find_mth_bitUtil ( int n , int m ) { int [ ] fib = new int [ maxN ] ; calculateFib ( fib , maxN ) ; int ans = find_mth_bit ( n , m , fib ) ; System . out . print ( ans + " ▁ " ) ; } public static void main ( String [ ] args ) { int n = 5 , m = 3 ; find_mth_bitUtil ( n , m ) ; } }

Index/key variables: maxN, x
Accumulator variables: x
Iterator variables: x
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int minAdjSwaps ( int [ ] [ ] mat ) { int N = mat . length ; int [ ] cntZero = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = N - 1 ; j >= 0 && mat [ i ] [ j ] == 0 ; j -- ) { cntZero [ i ] ++ ; } } int cntSwaps = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( cntZero [ i ] < ( N - i - 1 ) ) { int First = i ; while ( First < N && cntZero [ First ] < ( N - i - 1 ) ) { First ++ ; } if ( First == N ) { return - 1 ; } while ( First > i ) { cntZero = swap ( cntZero , First , First - 1 ) ; First -- ; cntSwaps ++ ; } } } return cntSwaps ; } static int [ ] swap ( int [ ] arr , int i , int j ) { int temp = arr [ i ] ; arr [ i ] = arr [ j ] ; arr [ j ] = temp ; return arr ; } public static void main ( String [ ] args ) { int [ ] [ ] mat = { { 0 , 0 , 2 } , { 3 , 1 , 0 } , { 4 , 0 , 0 } } ; System . out . print ( minAdjSwaps ( mat ) ) ; } }

Index/key variables: First, N, i, j
Accumulator variables: First, cntSwaps, i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { static void maxArea ( int [ ] point_x , int [ ] point_y , int n , int length , int width ) { Arrays . sort ( point_x ) ; Arrays . sort ( point_y ) ; int dx = point_x [ 0 ] ; int dy = point_y [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) { dx = Math . max ( dx , point_x [ i ] - point_x [ i - 1 ] ) ; dy = Math . max ( dy , point_y [ i ] - point_y [ i - 1 ] ) ; } dx = Math . max ( dx , ( length + 1 ) - point_x [ n - 1 ] ) ; dy = Math . max ( dy , ( width + 1 ) - point_y [ n - 1 ] ) ; System . out . println ( ( dx - 1 ) * ( dy - 1 ) ) ; } public static void main ( String [ ] args ) { int length = 15 , width = 8 ; int n = 3 ; int point_x [ ] = { 3 , 11 , 8 } ; int point_y [ ] = { 8 , 2 , 6 } ; maxArea ( point_x , point_y , n , length , width ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int make_cuts ( int arr [ ] , int n , int K ) { int ans = 0 ; Vector < Integer > poss = new Vector < Integer > ( ) ; int ce = 0 ; int co = 0 ; for ( int x = 0 ; x < n - 1 ; x ++ ) { if ( arr [ x ] % 2 == 0 ) ce ++ ; else co ++ ; if ( ce == co && co > 0 && ce > 0 ) { poss . add ( Math . abs ( arr [ x ] - arr [ x + 1 ] ) ) ; } } Collections . sort ( poss ) ; for ( int x : poss ) { if ( K >= x ) { ans ++ ; K -= x ; } else break ; } return ans ; } public static void main ( String [ ] args ) { int N = 6 ; int K = 4 ; int arr [ ] = { 1 , 2 , 5 , 10 , 15 , 20 } ; System . out . print ( make_cuts ( arr , N , K ) ) ; } }

Index/key variables: x
Accumulator variables: K, ans, ce, co, x
Iterator variables: x
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void Arrange ( int arr [ ] , int n ) { int cost = 0 ; HashMap < Integer , Integer > index = new HashMap < Integer , Integer > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { index . put ( arr [ i ] , i ) ; } Arrays . sort ( arr ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( i == 0 ) { if ( arr [ i ] > arr [ i + 1 ] + arr [ n - 1 ] ) { System . out . print ( " - 1" ) ; return ; } else { cost += Math . abs ( index . get ( arr [ i ] ) - i ) ; } } else if ( i == n - 1 ) { if ( arr [ i ] > arr [ i - 1 ] + arr [ 0 ] ) { System . out . print ( " - 1" ) ; return ; } else { cost += Math . abs ( index . get ( arr [ i ] ) - i ) ; } } else { if ( arr [ i ] > arr [ i - 1 ] + arr [ i + 1 ] ) { System . out . print ( " - 1" ) ; return ; } else { cost += Math . abs ( index . get ( arr [ i ] ) - i ) ; } } } System . out . print ( cost ) ; return ; } public static void main ( String [ ] args ) { int arr [ ] = { 2 , 4 , 5 , 1 , 3 } ; int N = arr . length ; Arrange ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: cost, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int XorSum ( int A [ ] , int B [ ] , int N ) { int ans = 0 ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) { ans = ans ^ ( A [ i ] + B [ j ] ) ; } } return ans ; } public static void main ( String [ ] args ) { int A [ ] = { 4 , 6 , 0 , 0 , 3 , 3 } ; int B [ ] = { 0 , 5 , 6 , 5 , 0 , 3 } ; int N = A . length ; System . out . println ( XorSum ( A , B , N ) ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int maxDistinctChar ( char [ ] s , int n , int k ) { HashMap < Integer , Integer > freq = new HashMap < Integer , Integer > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( freq . containsKey ( ( int ) s [ i ] ) ) { freq . put ( ( int ) s [ i ] , freq . get ( ( int ) s [ i ] ) + 1 ) ; } else { freq . put ( ( int ) s [ i ] , 1 ) ; } } Vector < Integer > v = new Vector < Integer > ( ) ; for ( Map . Entry < Integer , Integer > it : freq . entrySet ( ) ) { v . add ( it . getValue ( ) ) ; } Collections . sort ( v ) ; for ( int i = 0 ; i < v . size ( ) ; i ++ ) { int mn = Math . min ( v . get ( i ) - 1 , k ) ; v . set ( i , v . get ( i ) - mn ) ; k -= mn ; } if ( k > 0 ) { for ( int i = 0 ; i < v . size ( ) ; i ++ ) { int mn = Math . min ( v . get ( i ) , k ) ; v . set ( i , v . get ( i ) - mn ) ; k -= mn ; } } int res = 0 ; for ( int i = 0 ; i < v . size ( ) ; i ++ ) if ( v . get ( i ) == 1 ) res ++ ; return res ; } public static void main ( String [ ] args ) { String S = " geeksforgeeks " ; int N = S . length ( ) ; int K = 1 ; System . out . print ( maxDistinctChar ( S . toCharArray ( ) , N , K ) ) ; } }

Index/key variables: i
Accumulator variables: i, k, res
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static Vector < Integer > primes = new Vector < > ( ) ; static void SieveOfEratosthenes ( ) { boolean [ ] prime = new boolean [ 10005 ] ; Arrays . fill ( prime , true ) ; for ( int p = 2 ; p * p <= 1000 ; p ++ ) { if ( prime [ p ] == true ) { for ( int i = p * p ; i <= 1000 ; i += p ) prime [ i ] = false ; } } for ( int p = 2 ; p <= 1000 ; p ++ ) if ( prime [ p ] ) primes . add ( p ) ; } static void generate ( int n , int k ) { Vector < Integer > prod = new Vector < > ( ) ; SieveOfEratosthenes ( ) ; int l = primes . size ( ) ; for ( int i = 0 ; i < l ; i ++ ) { for ( int j = i + 1 ; j < l ; j ++ ) { if ( primes . get ( i ) * primes . get ( j ) > 0 ) prod . add ( primes . get ( i ) * primes . get ( j ) ) ; } } Collections . sort ( prod ) ; int sum = 0 ; for ( int i = 0 ; i < k - 1 ; i ++ ) sum += prod . get ( i ) ; if ( sum > n ) System . out . print ( " - 1" ) ; else { for ( int i = 0 ; i < k - 1 ; i ++ ) { System . out . print ( prod . get ( i ) + " , ▁ " ) ; } System . out . print ( n - sum + "NEW_LINE"); } } public static void main ( String [ ] args ) { int n = 52 , k = 5 ; generate ( n , k ) ; } }

Index/key variables: i, p
Accumulator variables: i, j, p, sum
Iterator variables: i, j, p
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int findMaxValue ( int arr [ ] , int n ) { Arrays . sort ( arr ) ; int ans = arr [ n - 1 ] ; int maxPossible = arr [ n - 1 ] ; for ( int i = n - 2 ; i >= 0 ; -- i ) { if ( maxPossible > 0 ) { if ( arr [ i ] >= maxPossible ) { ans += ( maxPossible - 1 ) ; maxPossible = maxPossible - 1 ; } else { maxPossible = arr [ i ] ; ans += maxPossible ; } } } return ans ; } public static void main ( String [ ] args ) { int arr [ ] = { 4 , 4 , 1 , 5 } ; int n = arr . length ; System . out . print ( findMaxValue ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: ans
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int minCost ( int arr [ ] , int n ) { int [ ] [ ] sorted = new int [ n ] [ 2 ] ; int total_cost = 0 ; for ( int i = 0 ; i < n ; i ++ ) { sorted [ i ] [ 0 ] = arr [ i ] ; sorted [ i ] [ 1 ] = i ; } Arrays . sort ( sorted , ( a , b ) -> a [ 0 ] - b [ 0 ] ) ; int overall_minimum = sorted [ 0 ] [ 0 ] ; boolean [ ] vis = new boolean [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { if ( vis [ i ] && sorted [ i ] [ 1 ] == i ) continue ; ArrayList < Integer > v = new ArrayList < > ( ) ; int j = i ; while ( ! vis [ j ] ) { vis [ j ] = true ; v . add ( sorted [ j ] [ 0 ] ) ; j = sorted [ j ] [ 1 ] ; } if ( v . size ( ) > 0 ) { int local_minimum = v . get ( 0 ) , result1 = 0 , result2 = 0 ; for ( int k = 1 ; k < v . size ( ) ; k ++ ) result1 += ( local_minimum * v . get ( k ) ) ; for ( int k = 0 ; k < v . size ( ) ; k ++ ) result2 += ( overall_minimum * v . get ( k ) ) ; result2 += ( overall_minimum * local_minimum ) ; total_cost += Math . min ( result1 , result2 ) ; } } return total_cost ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 8 , 9 , 7 , 6 } ; int n = arr . length ; System . out . print ( minCost ( arr , n ) ) ; } }

Index/key variables: i, j, n
Accumulator variables: i, k, result1, result2, total_cost
Iterator variables: i, k
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { public static int maximizeFinalElement ( int arr [ ] , int n ) { Arrays . sort ( arr ) ; if ( arr [ 0 ] != 1 ) arr [ 0 ] = 1 ; for ( int i = 1 ; i < n ; i ++ ) { if ( arr [ i ] - arr [ i - 1 ] > 1 ) { arr [ i ] = arr [ i - 1 ] + 1 ; } } return arr [ n - 1 ] ; } public static void main ( String [ ] args ) { int n = 4 ; int arr [ ] = { 3 , 1 , 3 , 4 } ; int max = maximizeFinalElement ( arr , n ) ; System . out . print ( max ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int findLeastDist ( int A [ ] , int N ) { Arrays . sort ( A ) ; if ( N % 2 == 0 ) { return A [ ( N - 1 ) / 2 ] ; } else { return A [ N / 2 ] ; } } public static void main ( String [ ] args ) { int A [ ] = { 4 , 1 , 5 , 10 , 2 } ; int N = A . length ; System . out . print ( " ( " + findLeastDist ( A , N ) + " , ▁ " + 0 + " ) " ) ; } }

Class/struct names: GFG
Java program:
class GFG { static int maxSubMatSum ( int [ ] [ ] mat ) { int n = mat . length ; int m = mat [ 0 ] . length ; int i , j ; int [ ] [ ] dp = new int [ n ] [ m ] ; dp [ n - 1 ] [ m - 1 ] = mat [ n - 1 ] [ m - 1 ] ; int res = dp [ n - 1 ] [ m - 1 ] ; for ( i = m - 2 ; i >= 0 ; i -- ) { dp [ n - 1 ] [ i ] = mat [ n - 1 ] [ i ] + dp [ n - 1 ] [ i + 1 ] ; res = Math . max ( res , dp [ n - 1 ] [ i ] ) ; } for ( i = n - 2 ; i >= 0 ; i -- ) { dp [ i ] [ m - 1 ] = mat [ i ] [ m - 1 ] + dp [ i + 1 ] [ m - 1 ] ; res = Math . max ( res , dp [ i ] [ m - 1 ] ) ; } for ( i = n - 2 ; i >= 0 ; i -- ) { for ( j = m - 2 ; j >= 0 ; j -- ) { dp [ i ] [ j ] = mat [ i ] [ j ] + dp [ i ] [ j + 1 ] + dp [ i + 1 ] [ j ] - dp [ i + 1 ] [ j + 1 ] ; res = Math . max ( res , dp [ i ] [ j ] ) ; } } return res ; } public static void main ( String [ ] args ) { int [ ] [ ] mat = { { - 6 , - 4 , - 1 } , { - 3 , 2 , 4 } , { 2 , 5 , 8 } } ; System . out . print ( maxSubMatSum ( mat ) ) ; } }

Index/key variables: i, j, m, n
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . Arrays ; public class PlacingNumbers { static String formAnInequality ( int [ ] integers , char [ ] inequalities ) { Arrays . sort ( integers ) ; int lowerIndex = 0 ; int higherIndex = integers . length - 1 ; StringBuilder sb = new StringBuilder ( ) ; for ( char ch : inequalities ) { if ( ch == ' < ' ) { sb . append ( " ▁ " + integers [ lowerIndex ++ ] + " ▁ " + ch ) ; } else { sb . append ( " ▁ " + integers [ higherIndex -- ] + " ▁ " + ch ) ; } } sb . append ( " ▁ " + integers [ lowerIndex ] ) ; return sb . toString ( ) ; } public static void main ( String [ ] args ) { int [ ] integers = { 2 , 5 , 1 , 0 } ; char [ ] inequalities = { ' < ' , ' > ' , ' < ' } ; String output = formAnInequality ( integers , inequalities ) ; System . out . println ( output ) ; } }

Index/key variables: lowerIndex
Accumulator variables: higherIndex, lowerIndex
Iterator variables: ch
Class/struct names: PlacingNumbers
Java program:
import java . util . * ; class GFG { public static boolean canMadeEqual ( int [ ] A , int [ ] B , int n ) { Arrays . sort ( A ) ; Arrays . sort ( B ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( A [ i ] != B [ i ] ) { return false ; } } return true ; } public static void main ( String [ ] args ) { int A [ ] = { 1 , 2 , 3 } ; int B [ ] = { 1 , 3 , 2 } ; int n = A . length ; if ( canMadeEqual ( A , B , n ) ) System . out . print ( " Yes " ) ; else System . out . print ( " No " ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . Arrays ; class GFG { static int maxMinDifference ( int arr [ ] , int n , int k ) { if ( k >= n - 1 ) return 0 ; Arrays . sort ( arr ) ; int ans = arr [ n - 1 ] - arr [ 0 ] ; for ( int i = k , j = n - 1 ; i >= 0 ; -- i , -- j ) { ans = Math . min ( arr [ j ] - arr [ i ] , ans ) ; } return ans ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 4 , 6 , 11 , 15 } ; int N = arr . length ; int K = 3 ; System . out . print ( maxMinDifference ( arr , N , K ) ) ; } }

Index/key variables: i, j
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; import java . lang . * ; class GFG { static class pair { int first , second ; pair ( int first , int second ) { this . first = first ; this . second = second ; } } static void max_sum ( int ar [ ] , int n , int q , int x [ ] , int y [ ] ) { int ans = 0 , i ; PriorityQueue < pair > pq = new PriorityQueue < > ( ( a , b ) -> Integer . compare ( a . second , b . second ) ) ; for ( i = 0 ; i < n ; i ++ ) pq . add ( new pair ( ar [ i ] , 1 ) ) ; for ( i = 0 ; i < q ; i ++ ) pq . add ( new pair ( y [ i ] , x [ i ] ) ) ; while ( n > 0 ) { pair pr = pq . peek ( ) ; pq . poll ( ) ; ans += pr . first * Math . min ( n , pr . second ) ; n -= pr . second ; } System . out . println ( ans ) ; } public static void main ( String [ ] args ) { int ar [ ] = { 200 , 100 , 200 , 300 } ; int n = ar . length ; int q = 2 ; int x [ ] = { 2 , 3 } ; int y [ ] = { 100 , 90 } ; max_sum ( ar , n , q , x , y ) ; } }

Index/key variables: i
Accumulator variables: ans, i, n
Iterator variables: i
Class/struct names: GFG, pair
Java program:
class GFG { static void sortarray ( int arr [ ] , int N ) { if ( N == 3 ) System . out . println ( " NO " ) ; else if ( N % 4 == 0 N % 4 == 1 ) { System . out . println ( " YES " ) ; System . out . println ( N / 2 ) ; int k = 1 , l ; for ( l = 0 ; l < ( N / 4 ) ; l ++ ) { System . out . println ( k + " ▁ " + ( k + 1 ) + " ▁ " + N ) ; System . out . println ( k + 1 + " ▁ " + N + " ▁ " + ( N - 1 ) ) ; k = k + 2 ; N = N - 2 ; } } else System . out . println ( " NO " ) ; } public static void main ( String [ ] args ) { int N = 5 ; int arr [ ] = { 5 , 4 , 3 , 2 , 1 } ; sortarray ( arr , N ) ; } }

Accumulator variables: l
Iterator variables: l
Class/struct names: GFG
Java program:
class GFG { static int MAX = ( int ) ( 1e5 + 5 ) ; static class pair { int first , second ; public pair ( int first , int second ) { this . first = first ; this . second = second ; } } static void find_missing ( pair [ ] interval ) { int [ ] vis = new int [ MAX ] ; for ( int i = 0 ; i < interval . length ; ++ i ) { int start = interval [ i ] . first ; int end = interval [ i ] . second ; vis [ start ] ++ ; vis [ end + 1 ] -- ; } for ( int i = 1 ; i < MAX ; i ++ ) { vis [ i ] += vis [ i - 1 ] ; if ( vis [ i ] == 0 ) { System . out . print ( i + "NEW_LINE"); return ; } } } public static void main ( String [ ] args ) { pair [ ] interval = { new pair ( 0 , 14 ) , new pair ( 86 , 108 ) , new pair ( 22 , 30 ) , new pair ( 5 , 17 ) } ; find_missing ( interval ) ; } }

Index/key variables: MAX, i, start
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG, pair