dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
import java . util . * ; import java . io . * ; class GFG { static class Pair implements Comparable < Pair > { int start , end ; Pair ( int s , int e ) { start = s ; end = e ; } public int compareTo ( Pair p ) { return this . start - p . start ; } } static void findMissing ( ArrayList < Pair > interval ) { Collections . sort ( interval ) ; int mx = 0 ; for ( int i = 0 ; i < interval . size ( ) ; ++ i ) { if ( interval . get ( i ) . start > mx ) { System . out . println ( mx ) ; return ; } else mx = Math . max ( mx , interval . get ( i ) . end + 1 ) ; } System . out . println ( mx ) ; } public static void main ( String [ ] args ) { ArrayList < Pair > interval = new ArrayList < > ( ) ; interval . add ( new Pair ( 0 , 14 ) ) ; interval . add ( new Pair ( 86 , 108 ) ) ; interval . add ( new Pair ( 22 , 30 ) ) ; interval . add ( new Pair ( 5 , 17 ) ) ; findMissing ( interval ) ; } }

Iterator variables: i
Class/struct names: GFG, Pair
Java program:
class GFG { static int build_num ( int [ ] bit ) { int ans = 0 ; for ( int i = 0 ; i < 32 ; i ++ ) if ( bit [ i ] == 1 ) ans += ( 1 << i ) ; ans += 32 ; return ans ; } static int maximumOR ( int [ ] arr , int n , int k ) { int bit [ ] = new int [ 32 ] ; for ( int i = 31 ; i >= 0 ; i -- ) { if ( bit [ i ] == 0 && k > 0 ) { int temp = build_num ( bit ) ; int temp1 = temp ; int val = - 1 ; for ( int j = 0 ; j < n ; j ++ ) { if ( temp1 < ( temp arr [ j ] ) ) { temp1 = temp | arr [ j ] ; val = arr [ j ] ; } } if ( val != - 1 ) { k -- ; for ( int j = 0 ; j < 32 ; j ++ ) { bit [ j ] ++ ; } } } } return build_num ( bit ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 5 , 9 , 7 , 19 } ; int k = 3 ; int n = arr . length ; System . out . println ( maximumOR ( arr , n , k ) ) ; } }

Index/key variables: i, j
Accumulator variables: ans, i, j, k
Iterator variables: i, j
Class/struct names: GFG
Java program:
class GFG { static void smallest_String ( char [ ] s , int m ) { int n = s . length ; int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { int distance = s [ i ] - ' a ' ; if ( distance == 0 ) a [ i ] = 0 ; else a [ i ] = 26 - distance ; } for ( int i = 0 ; i < n ; i ++ ) { if ( m >= a [ i ] ) { s [ i ] = ' a ' ; m = m - a [ i ] ; } } m = m % 26 ; s [ n - 1 ] = ( char ) ( s [ n - 1 ] + m ) ; System . out . print ( String . valueOf ( s ) ) ; } public static void main ( String [ ] args ) { String str = " aazzx " ; int m = 6 ; smallest_String ( str . toCharArray ( ) , m ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { static int find_maximum_jobs ( int N , ArrayList < ArrayList < Integer > > ranges ) { ArrayList < Integer > queue = new ArrayList < Integer > ( ) ; Collections . sort ( ranges , new Comparator < ArrayList < Integer > > ( ) { @ Override public int compare ( ArrayList < Integer > o1 , ArrayList < Integer > o2 ) { return o1 . get ( 0 ) . compareTo ( o2 . get ( 0 ) ) ; } } ) ; int min_day = ranges . get ( 0 ) . get ( 0 ) ; int max_day = 0 ; for ( int i = 0 ; i < N ; i ++ ) max_day = Math . max ( max_day , ranges . get ( i ) . get ( 1 ) ) ; int index = 0 , count_jobs = 0 ; for ( int i = min_day ; i <= max_day ; i ++ ) { while ( index < ranges . size ( ) && ranges . get ( index ) . get ( 0 ) <= i ) { queue . add ( ranges . get ( index ) . get ( 1 ) ) ; index ++ ; } Collections . sort ( queue ) ; while ( queue . size ( ) > 0 && queue . get ( 0 ) < i ) queue . remove ( 0 ) ; if ( queue . size ( ) == 0 ) continue ; count_jobs ++ ; queue . remove ( 0 ) ; } return count_jobs ; } public static void main ( String [ ] args ) { int N = 5 ; ArrayList < ArrayList < Integer > > ranges = new ArrayList < ArrayList < Integer > > ( ) ; ranges . add ( new ArrayList < Integer > ( Arrays . asList ( 1 , 5 ) ) ) ; ranges . add ( new ArrayList < Integer > ( Arrays . asList ( 1 , 5 ) ) ) ; ranges . add ( new ArrayList < Integer > ( Arrays . asList ( 1 , 5 ) ) ) ; ranges . add ( new ArrayList < Integer > ( Arrays . asList ( 2 , 3 ) ) ) ; ranges . add ( new ArrayList < Integer > ( Arrays . asList ( 2 , 3 ) ) ) ; System . out . println ( find_maximum_jobs ( N , ranges ) ) ; } }

Accumulator variables: count_jobs, i, index
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . Arrays ; class GFG { public static void minBox ( int arr [ ] , int n ) { int box = n ; Arrays . sort ( arr ) ; int curr_box = 0 , next_box = 1 ; while ( curr_box < n && next_box < n ) { if ( arr [ curr_box ] < arr [ next_box ] ) { box -- ; curr_box ++ ; next_box ++ ; } else if ( arr [ curr_box ] == arr [ next_box ] ) next_box ++ ; } System . out . println ( box ) ; } public static void main ( String args [ ] ) { int [ ] size = { 1 , 2 , 3 } ; int n = size . length ; minBox ( size , n ) ; } }

Index/key variables: curr_box, next_box
Accumulator variables: box, curr_box, next_box
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int countReductions ( ArrayList < int [ ] > v , int K ) { int sum = 0 ; for ( int [ ] i : v ) { sum += i [ 0 ] ; } if ( sum <= K ) { return 0 ; } Collections . sort ( v , ( a , b ) -> Math . abs ( b [ 0 ] - b [ 1 ] ) - Math . abs ( a [ 0 ] - a [ 1 ] ) ) ; int i = 0 ; while ( sum > K && i < v . size ( ) ) { sum -= ( v . get ( i ) [ 0 ] - v . get ( i ) [ 1 ] ) ; i ++ ; } if ( sum <= K ) return i ; return - 1 ; } public static void main ( String [ ] args ) { int N = 4 , K = 25 ; ArrayList < int [ ] > v = new ArrayList < > ( ) ; v . add ( new int [ ] { 10 , 5 } ) ; v . add ( new int [ ] { 20 , 9 } ) ; v . add ( new int [ ] { 12 , 10 } ) ; v . add ( new int [ ] { 4 , 2 } ) ; System . out . println ( countReductions ( v , K ) ) ; } }

Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static node head1 = null ; static node head2 = null ; static class node { int data ; node next ; } ; static void setData ( node head ) { node tmp ; tmp = head ; while ( tmp != null ) { System . out . print ( tmp . data + " ▁ - > ▁ " ) ; tmp = tmp . next ; } } static node getData ( node head , int num ) { node temp = new node ( ) ; node tail = head ; temp . data = num ; temp . next = null ; if ( head == null ) { head = temp ; tail = temp ; } else { while ( tail != null ) { if ( tail . next == null ) { tail . next = temp ; tail = tail . next ; } tail = tail . next ; } } return head ; } static node mergelists ( ) { node tail = head1 ; while ( tail != null ) { if ( tail . next == null && head2 != null ) { tail . next = head2 ; break ; } tail = tail . next ; } return head1 ; } static void sortlist ( ) { node curr = head1 ; node temp = head1 ; while ( curr . next != null ) { temp = curr . next ; while ( temp != null ) { if ( temp . data < curr . data ) { int t = temp . data ; temp . data = curr . data ; curr . data = t ; } temp = temp . next ; } curr = curr . next ; } } public static void main ( String [ ] args ) { head1 = getData ( head1 , 4 ) ; head1 = getData ( head1 , 7 ) ; head1 = getData ( head1 , 5 ) ; head2 = getData ( head2 , 2 ) ; head2 = getData ( head2 , 1 ) ; head2 = getData ( head2 , 8 ) ; head2 = getData ( head2 , 1 ) ; head1 = mergelists ( ) ; sortlist ( ) ; setData ( head1 ) ; } }

Class/struct names: GFG, node
Java program:
import java . util . * ; class GFG { static double findMedian ( int a [ ] , int n ) { if ( n % 2 != 0 ) return ( double ) a [ n / 2 ] ; return ( double ) ( a [ ( n - 1 ) / 2 ] + a [ n / 2 ] ) / 2.0 ; } static void kStrongest ( int arr [ ] , int n , int k ) { Arrays . sort ( arr ) ; double median = findMedian ( arr , n ) ; int [ ] diff = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { diff [ i ] = ( int ) Math . abs ( median - arr [ i ] ) ; } int i = 0 , j = n - 1 ; while ( k > 0 ) { if ( diff [ i ] > diff [ j ] ) { System . out . print ( arr [ i ] + " ▁ " ) ; i ++ ; } else { System . out . print ( arr [ j ] + " ▁ " ) ; j -- ; } k -- ; } } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 3 , 4 , 5 } ; int k = 3 ; int n = arr . length ; kStrongest ( arr , n , k ) ; } }

Index/key variables: i, j, n
Accumulator variables: i, j, k
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static boolean sorting_possible ( int a [ ] , int b [ ] , int n ) { boolean sorted = true ; int type1 = 0 , type0 = 0 , i ; for ( i = 1 ; i < n ; i ++ ) { if ( a [ i ] < a [ i - 1 ] ) { sorted = false ; break ; } } for ( i = 0 ; i < n ; i ++ ) { if ( b [ i ] == 0 ) type0 ++ ; else type1 ++ ; } if ( sorted ) return true ; else if ( type1 == n type0 == n ) return false ; else return true ; } public static void main ( String [ ] args ) { int a [ ] = { 15 , 1 , 2 , 17 , 6 } ; int b [ ] = { 1 , 1 , 0 , 1 , 1 } ; int n = a . length ; boolean res = sorting_possible ( a , b , n ) ; if ( res ) System . out . print ( " Yes " ) ; else System . out . print ( " No " ) ; } }

Index/key variables: i
Accumulator variables: i, type0, type1
Iterator variables: i
Boolean variables: sorted
Class/struct names: GFG
Java program:
import java . util . ArrayList ; import java . util . HashSet ; import java . util . List ; import java . util . Set ; class Pair { int first , second ; public Pair ( int first , int second ) { this . first = first ; this . second = second ; } } class GFG { static final int infi = 1000000000 ; static class Node { int vertexNumber ; List < Pair > children ; Node ( int vertexNumber ) { this . vertexNumber = vertexNumber ; children = new ArrayList < > ( ) ; } void add_child ( int vNumber , int length ) { Pair p = new Pair ( vNumber , length ) ; children . add ( p ) ; } } static int [ ] dijkstraDist ( List < Node > g , int s , int [ ] path ) { int [ ] dist = new int [ g . size ( ) ] ; boolean [ ] visited = new boolean [ g . size ( ) ] ; for ( int i = 0 ; i < g . size ( ) ; i ++ ) { visited [ i ] = false ; path [ i ] = - 1 ; dist [ i ] = infi ; } dist [ s ] = 0 ; path [ s ] = - 1 ; int current = s ; Set < Integer > sett = new HashSet < > ( ) ; while ( true ) { visited [ current ] = true ; for ( int i = 0 ; i < g . get ( current ) . children . size ( ) ; i ++ ) { int v = g . get ( current ) . children . get ( i ) . first ; if ( visited [ v ] ) continue ; sett . add ( v ) ; int alt = dist [ current ] + g . get ( current ) . children . get ( i ) . second ; if ( alt < dist [ v ] ) { dist [ v ] = alt ; path [ v ] = current ; } } sett . remove ( current ) ; if ( sett . isEmpty ( ) ) break ; int minDist = infi ; int index = 0 ; for ( int a : sett ) { if ( dist [ a ] < minDist ) { minDist = dist [ a ] ; index = a ; } } current = index ; } return dist ; } void printPath ( int [ ] path , int i , int s ) { if ( i != s ) { if ( path [ i ] == - 1 ) { System . out . println ( " Path ▁ not ▁ found ! ! " ) ; return ; } printPath ( path , path [ i ] , s ) ; System . out . print ( path [ i ] + " ▁ " ) ; } } public static void main ( String [ ] args ) { List < Node > v = new ArrayList < > ( ) ; int n = 4 , s = 0 , e = 5 ; for ( int i = 0 ; i < n ; i ++ ) { Node a = new Node ( i ) ; v . add ( a ) ; } v . get ( 0 ) . add_child ( 1 , 1 ) ; v . get ( 0 ) . add_child ( 2 , 4 ) ; v . get ( 1 ) . add_child ( 2 , 2 ) ; v . get ( 1 ) . add_child ( 3 , 6 ) ; v . get ( 2 ) . add_child ( 3 , 3 ) ; int [ ] path = new int [ v . size ( ) ] ; int [ ] dist = dijkstraDist ( v , s , path ) ; for ( int i = 0 ; i < dist . length ; i ++ ) { if ( dist [ i ] == infi ) { System . out . printf ( " % d ▁ and ▁ % d ▁ are ▁ not ▁ " + "connectedNEW_LINE", i, s); continue ; } System . out . printf ( " Distance ▁ of ▁ % dth ▁ vertex ▁ " + "from source vertex %d is: %dNEW_LINE", i, s, dist[i]); } } }

Index/key variables: a, current, i, s, v
Accumulator variables: i
Iterator variables: a, i
Class/struct names: GFG, Node, Pair
Java program:
import java . util . * ; class GFG { public static void maximizeval10 ( int [ ] a , int n , int k ) { int increments = 0 ; int ans = 0 ; Vector < Integer > v = new Vector < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { ans += ( a [ i ] / 10 ) ; if ( a [ i ] == 1000 ) continue ; else { v . add ( 10 - a [ i ] % 10 ) ; increments += ( 100 - ( ( a [ i ] ) / 10 ) - 1 ) ; } } Collections . sort ( v ) ; int sum = 0 ; for ( int i = 0 ; i < v . size ( ) ; i ++ ) { sum += v . get ( i ) ; if ( sum <= k ) { ans ++ ; } else break ; } if ( sum < k ) { int remaining = k - sum ; ans += Math . min ( increments , remaining / 10 ) ; } System . out . print ( ans ) ; } public static void main ( String [ ] args ) { int N = 4 ; int X = 6 ; int A [ ] = { 4 , 8 , 8 , 8 } ; maximizeval10 ( A , N , X ) ; } }

Index/key variables: i
Accumulator variables: ans, i, increments, sum
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int findMinDif ( int arr [ ] , int N ) { Arrays . sort ( arr ) ; return ( arr [ N - 1 ] - arr [ N - 2 ] ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 7 , 9 , 5 , 10 } ; int N = arr . length ; System . out . println ( findMinDif ( arr , N ) ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int partition ( int arr [ ] , int l , int h ) { int pivot = arr [ l ] ; int i = l + 1 ; int j = h ; while ( i <= j ) { while ( i <= h && arr [ i ] < pivot ) { i ++ ; } while ( j > l && arr [ j ] > pivot ) { j -- ; } if ( i < j ) { int temp = arr [ i ] ; arr [ i ] = arr [ j ] ; arr [ j ] = temp ; i ++ ; j -- ; } else i ++ ; } arr [ l ] = arr [ j ] ; arr [ j ] = pivot ; return j ; } static void sortArray ( int arr [ ] , int l , int h ) { if ( l >= h ) return ; int pivot = partition ( arr , l , h ) ; sortArray ( arr , l , pivot - 1 ) ; sortArray ( arr , pivot + 1 , h ) ; } static int findMaxIntervals ( int start [ ] , int end [ ] , int n , int R ) { int ans = 0 ; int prev = 0 ; int currActive = 0 ; int i = 0 ; int j = 0 ; if ( start [ 0 ] > 0 ) ans ++ ; while ( i < n && j < n ) { if ( start [ i ] < end [ j ] ) { i ++ ; currActive ++ ; } else if ( start [ i ] > end [ j ] ) { j ++ ; currActive -- ; } else { i ++ ; j ++ ; } if ( currActive == 0 ) { ans ++ ; } } if ( end [ n - 1 ] < R ) ans ++ ; return ans ; } public static void main ( String args [ ] ) { int R , N ; R = 10 ; N = 3 ; int start [ ] = new int [ ] { 2 , 5 , 8 } ; int end [ ] = new int [ ] { 3 , 9 , 10 } ; sortArray ( start , 0 , N - 1 ) ; sortArray ( end , 0 , N - 1 ) ; System . out . print ( findMaxIntervals ( start , end , N , R ) ) ; } }

Index/key variables: i, j, l
Accumulator variables: ans, currActive, i, j
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { static int number ( int [ ] a , int n , int p , int k ) { Arrays . sort ( a ) ; int [ ] pre = new int [ n ] ; int val , i , j , ans = 0 ; pre [ 0 ] = a [ 0 ] ; if ( pre [ 0 ] <= p ) ans = 1 ; for ( i = 1 ; i < k - 1 ; i ++ ) { pre [ i ] = pre [ i - 1 ] + a [ i ] ; if ( pre [ i ] <= p ) ans = i + 1 ; } pre [ k - 1 ] = a [ k - 1 ] ; for ( i = k - 1 ; i < n ; i ++ ) { if ( i >= k ) { pre [ i ] += pre [ i - k ] + a [ i ] ; } if ( pre [ i ] <= p ) ans = i + 1 ; } return ans ; } public static void main ( String [ ] args ) { int n = 5 ; int [ ] arr = { 2 , 4 , 3 , 5 , 7 } ; int p = 11 ; int k = 2 ; System . out . println ( number ( arr , n , p , k ) ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void sieveOfEratosthenes ( boolean prime [ ] , int n ) { prime [ 0 ] = 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 sortSpecialPrimes ( int arr [ ] , int n ) { int maxVal = Arrays . stream ( arr ) . max ( ) . getAsInt ( ) ; boolean [ ] prime = new boolean [ maxVal + 1 ] ; for ( int i = 0 ; i < prime . length ; i ++ ) prime [ i ] = true ; sieveOfEratosthenes ( prime , maxVal ) ; Vector < Integer > list = new Vector < Integer > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( prime [ arr [ i ] ] && prime [ arr [ i ] - 2 ] ) { list . add ( arr [ i ] ) ; arr [ i ] = - 1 ; } } Collections . sort ( list ) ; int j = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] == - 1 ) System . out . print ( list . get ( j ++ ) + " ▁ " ) ; else System . out . print ( arr [ i ] + " ▁ " ) ; } } public static void main ( String [ ] args ) { int arr [ ] = { 31 , 5 , 2 , 1 , 7 } ; int n = arr . length ; sortSpecialPrimes ( arr , n ) ; } }

Index/key variables: i, p
Accumulator variables: i, j, p
Iterator variables: i, p
Class/struct names: GFG
Java program:
import java . util . Arrays ; import java . util . Collections ; public class GFG { static int maxProfit ( Integer [ ] arr ) { Arrays . sort ( arr , Collections . reverseOrder ( ) ) ; int ans = 0 ; for ( int i = 0 ; i < arr . length ; i ++ ) { if ( ( arr [ i ] - ( 1 * i ) ) > 0 ) ans += ( arr [ i ] - ( 1 * i ) ) ; if ( ( arr [ i ] - ( 1 * i ) ) == 0 ) break ; } return ans ; } public static void main ( String [ ] args ) { Integer arr [ ] = { 6 , 6 , 6 } ; System . out . println ( maxProfit ( arr ) ) ; } }

Index/key variables: i
Accumulator variables: ans, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . Arrays ; class GFG { public static void check_vector ( int [ ] A , int n , int [ ] p ) { int [ ] pos = new int [ A . length ] ; for ( int i = 0 ; i < p . length ; i ++ ) { pos [ p [ i ] - 1 ] = 1 ; } int flag = 1 ; for ( int i = 0 ; i < n ; i ++ ) { if ( pos [ i ] == 0 ) continue ; int j = i ; while ( j < n && pos [ j ] != 0 ) ++ j ; Arrays . sort ( A , i , j + 1 ) ; i = j ; } for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( A [ i ] > A [ i + 1 ] ) { flag = 0 ; break ; } } if ( flag == 1 ) System . out . print ( " Yes " ) ; else System . out . print ( " No " ) ; } public static void main ( String [ ] args ) { int A [ ] = { 3 , 2 , 1 } ; int p [ ] = { 1 , 2 } ; check_vector ( A , A . length , p ) ; } }

Index/key variables: i, j
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void sortDiff ( Vector < Integer > arr , int n ) { Collections . sort ( arr ) ; Vector < Integer > out = new Vector < Integer > ( ) ; while ( n > 0 ) { out . add ( arr . get ( n / 2 ) ) ; arr . remove ( n / 2 ) ; n = n - 1 ; } for ( int i : out ) System . out . print ( i + " ▁ " ) ; } public static void main ( String [ ] args ) { Integer [ ] a = { 8 , 1 , 2 , 3 , 0 } ; Vector < Integer > arr = new Vector < Integer > ( Arrays . asList ( a ) ) ; int n = 5 ; sortDiff ( arr , n ) ; } }

Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void minimumCost ( int arr [ ] , int N , int M ) { Arrays . sort ( arr ) ; int [ ] pref = new int [ N ] ; pref [ 0 ] = arr [ 0 ] ; for ( int i = 1 ; i < N ; i ++ ) { pref [ i ] = arr [ i ] + pref [ i - 1 ] ; } for ( int i = M ; i < N ; i ++ ) { pref [ i ] += pref [ i - M ] ; } for ( int i = 0 ; i < N ; i ++ ) { System . out . print ( pref [ i ] + " ▁ " ) ; } } public static void main ( String [ ] args ) { int arr [ ] = { 6 , 19 , 3 , 4 , 4 , 2 , 6 , 7 , 8 } ; int M = 2 ; int N = arr . length ; minimumCost ( arr , N , M ) ; } }

Index/key variables: N, i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int uniqueSum ( int A [ ] , int R [ ] [ ] , int N , int M ) { for ( int i = 0 ; i < M ; ++ i ) { int l = R [ i ] [ 0 ] , r = R [ i ] [ 1 ] + 1 ; l -- ; r -- ; A [ l ] ++ ; if ( r < N ) A [ r ] -- ; } for ( int i = 1 ; i < N ; ++ i ) { A [ i ] += A [ i - 1 ] ; } int ans = 0 ; HashSet < Integer > s = new HashSet < Integer > ( ) ; for ( int i = 0 ; i < N ; ++ i ) { if ( ! s . contains ( A [ i ] ) ) ans += A [ i ] ; s . add ( A [ i ] ) ; } return ans ; } public static void main ( String [ ] args ) { int A [ ] = { 0 , 0 , 0 , 0 , 0 , 0 } ; int R [ ] [ ] = { { 1 , 3 } , { 4 , 6 } , { 3 , 4 } , { 3 , 3 } } ; int N = A . length ; int M = R . length ; System . out . print ( uniqueSum ( A , R , N , M ) ) ; } }

Index/key variables: i, l, r
Accumulator variables: ans, l, r
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void kthpair ( int n , int k , int arr [ ] ) { int i , t = 0 ; Arrays . sort ( arr ) ; -- k ; for ( i = 0 ; i < n ; i += t ) { for ( t = 1 ; arr [ i ] == arr [ i + t ] ; ++ t ) ; if ( t * n > k ) break ; k = k - t * n ; } System . out . print ( arr [ i ] + " ▁ " + arr [ k / t ] ) ; } public static void main ( String [ ] args ) { int n = 3 , k = 2 ; int arr [ ] = { 3 , 1 , 5 } ; kthpair ( n , k , arr ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i, t
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int minOperations ( String s ) { Integer freq [ ] = new Integer [ 26 ] ; Arrays . fill ( freq , 0 ) ; int n = s . length ( ) ; for ( int i = 0 ; i < n ; i ++ ) { freq [ s . charAt ( i ) - ' A ' ] ++ ; } Arrays . sort ( freq , Collections . reverseOrder ( ) ) ; int answer = n ; for ( int i = 1 ; i <= 26 ; i ++ ) { if ( n % i == 0 ) { int x = n / i ; int y = 0 ; for ( int j = 0 ; j < i ; j ++ ) { y += Math . min ( freq [ j ] , x ) ; } answer = Math . min ( answer , n - y ) ; } } return answer ; } public static void main ( String [ ] args ) { String s = " BBC " ; System . out . print ( minOperations ( s ) ) ; } }

Index/key variables: j
Accumulator variables: i, j, y
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . lang . * ; import java . io . * ; import java . util . * ; class GFG { public static boolean fun ( int [ ] arr , int n , int k ) { Vector < Integer > v = new Vector < Integer > ( ) ; for ( int i = 0 ; i < k ; i ++ ) { for ( int j = i ; j < n ; j += k ) { v . add ( arr [ j ] ) ; } Collections . sort ( v ) ; int x = 0 ; for ( int j = i ; j < n ; j += k ) { arr [ j ] = v . get ( x ) ; x ++ ; } v . clear ( ) ; } for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( arr [ i ] > arr [ i + 1 ] ) { return false ; } } return true ; } public static void main ( String args [ ] ) { int [ ] arr = { 4 , 2 , 3 , 7 , 6 } ; int K = 2 ; int n = arr . length ; if ( fun ( arr , n , K ) ) { System . out . println ( " yes " ) ; } else { System . out . println ( " no " ) ; } } }

Index/key variables: i, j
Accumulator variables: i, j, x
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void sortedAdjacentDifferences ( int arr [ ] , int n ) { int [ ] ans = new int [ n ] ; Arrays . sort ( arr ) ; int l = 0 , r = n - 1 ; for ( int i = n - 1 ; i >= 0 ; i -- ) { if ( i % 2 == 1 ) { ans [ i ] = arr [ l ] ; l ++ ; } else { ans [ i ] = arr [ r ] ; r -- ; } } for ( int i = 0 ; i < n ; i ++ ) { System . out . print ( ans [ i ] + " ▁ " ) ; } } public static void main ( String [ ] args ) { int arr [ ] = { 5 , - 2 , 4 , 8 , 6 , 4 , 5 } ; int n = arr . length ; sortedAdjacentDifferences ( arr , n ) ; } }

Index/key variables: i, l, n, r
Accumulator variables: i, l, r
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int get_permutation ( int arr [ ] , int n ) { Arrays . sort ( arr ) ; int result = 0 ; for ( int i = 0 ; i < n ; i ++ ) { result += Math . abs ( arr [ i ] - ( i + 1 ) ) ; } return result ; } public static void main ( String [ ] args ) { int arr [ ] = { 0 , 2 , 3 , 4 , 1 , 6 , 8 , 9 } ; int n = arr . length ; System . out . print ( get_permutation ( arr , n ) ) ; } }

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