dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
import java . util . * ; class GFG { static int MAX = 100001 ; static class interval { int l , r , v ; } static class Sort implements Comparator < interval > { public int compare ( interval a , interval b ) { return ( a . v < b . v ? 1 : 0 ) ; } } static boolean isPossible ( int range [ ] [ ] , int N ) { interval test [ ] = new interval [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { test [ i ] = new interval ( ) ; test [ i ] . l = range [ i ] [ 0 ] ; test [ i ] . r = range [ i ] [ 1 ] ; test [ i ] . v = range [ i ] [ 2 ] ; } Arrays . sort ( test , new Sort ( ) ) ; for ( int i = 0 ; i < N ; i ++ ) { int count [ ] = new int [ MAX ] ; int current_velocity = test [ i ] . v ; int j = i ; while ( j < N && test [ j ] . v == current_velocity ) { for ( int k = test [ j ] . l ; k <= test [ j ] . r ; k ++ ) { count [ k ] ++ ; if ( count [ k ] >= 3 ) return false ; } j ++ ; } i = j - 1 ; } return true ; } public static void main ( String args [ ] ) { int range [ ] [ ] = { { 1 , 2 , 3 } , { 2 , 5 , 1 } , { 3 , 10 , 1 } , { 4 , 4 , 1 } , { 5 , 7 , 10 } } ; int n = range . length ; if ( isPossible ( range , n ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } }

Index/key variables: MAX, N, i, j, k
Accumulator variables: i, j, k
Iterator variables: i, k
Class/struct names: GFG, Sort, interval
Java program:
import java . util . * ; class GFG { static int N = 2005 ; static Set < Integer > ans = new LinkedHashSet < Integer > ( ) ; static void dfs ( int num , int left , int ct ) { if ( ct >= 15 ) return ; if ( left == 0 ) ans . add ( num ) ; for ( int i = 0 ; i <= Math . min ( left , 9 ) ; i ++ ) dfs ( num * 10 + i , left - i , ct + 1 ) ; } static int getKthNum ( int m , int k ) { dfs ( 0 , m , 0 ) ; int ct = 0 ; for ( int it : ans ) { ct ++ ; if ( ct == k ) { return it ; } } return - 1 ; } public static void main ( String [ ] args ) { int m = 5 , k = 3 ; System . out . println ( getKthNum ( m , k ) ) ; } }

Accumulator variables: ct, i
Iterator variables: i, it
Class/struct names: GFG
Java program:
import java . util . Arrays ; class GFG { public static int upperBound ( int [ ] array , int value ) { int low = 0 ; int high = array . length ; while ( low < high ) { final int mid = ( low + high ) / 2 ; if ( value >= array [ mid ] ) { low = mid + 1 ; } else { high = mid ; } } return low ; } public static int Removal ( int [ ] v , int n ) { Arrays . sort ( v ) ; int ans = Integer . MAX_VALUE ; int k = 0 ; for ( int i : v ) { int j = upperBound ( v , ( 2 * i ) ) ; ans = Math . min ( ans , n - ( j - k ) ) ; k ++ ; } return ans ; } public static void main ( String [ ] args ) { int [ ] a = { 4 , 5 , 100 , 9 , 10 , 11 , 12 , 15 , 200 } ; int n = a . length ; System . out . println ( Removal ( a , n ) ) ; } }

Index/key variables: mid
Accumulator variables: k
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void FrontToLast ( Queue < Integer > q , int qsize ) { if ( qsize <= 0 ) return ; q . add ( q . peek ( ) ) ; q . remove ( ) ; FrontToLast ( q , qsize - 1 ) ; } static void pushInQueue ( Queue < Integer > q , int temp , int qsize ) { if ( q . isEmpty ( ) qsize == 0 ) { q . add ( temp ) ; return ; } else if ( temp <= q . peek ( ) ) { q . add ( temp ) ; FrontToLast ( q , qsize ) ; } else { q . add ( q . peek ( ) ) ; q . remove ( ) ; pushInQueue ( q , temp , qsize - 1 ) ; } } static void sortQueue ( Queue < Integer > q ) { if ( q . isEmpty ( ) ) return ; int temp = q . peek ( ) ; q . remove ( ) ; sortQueue ( q ) ; pushInQueue ( q , temp , q . size ( ) ) ; } public static void main ( String [ ] args ) { Queue < Integer > qu = new LinkedList < > ( ) ; qu . add ( 10 ) ; qu . add ( 7 ) ; qu . add ( 16 ) ; qu . add ( 9 ) ; qu . add ( 20 ) ; qu . add ( 5 ) ; sortQueue ( qu ) ; while ( ! qu . isEmpty ( ) ) { System . out . print ( qu . peek ( ) + " ▁ " ) ; qu . remove ( ) ; } } }

Class/struct names: GFG
Java program:
class GFG { static int partition ( char arr [ ] , int low , int high , int mod ) { char pivot = arr [ high ] ; int i = ( low - 1 ) ; int piv = pivot % mod ; for ( int j = low ; j <= high - 1 ; j ++ ) { int a = arr [ j ] % mod ; if ( a <= piv ) { i ++ ; char t = arr [ i ] ; arr [ i ] = arr [ j ] ; arr [ j ] = t ; } } char t = arr [ i + 1 ] ; arr [ i + 1 ] = arr [ high ] ; arr [ high ] = t ; return ( i + 1 ) ; } static void quickSort ( char arr [ ] , int low , int high , int mod ) { if ( low < high ) { int pi = partition ( arr , low , high , mod ) ; quickSort ( arr , low , pi - 1 , mod ) ; quickSort ( arr , pi + 1 , high , mod ) ; } } static void printArray ( char arr [ ] , int size ) { for ( int i = 0 ; i < size ; i ++ ) System . out . print ( arr [ i ] + " ▁ " ) ; } public static void main ( String [ ] args ) { char arr [ ] = { ' g ' , ' e ' , ' e ' , ' k ' , ' s ' } ; int n = arr . length ; int mod = 8 ; quickSort ( arr , 0 , n - 1 , mod ) ; printArray ( arr , n ) ; } }

Index/key variables: high, i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . ArrayList ; class GFG { static class node { int data ; node left , right ; public node ( int x ) { data = x ; left = right = null ; } } ; static void insertionSort ( ArrayList < Integer > v , int n ) { int i , key , j ; for ( i = 1 ; i < n ; i ++ ) { key = v . get ( i ) ; j = i - 1 ; while ( j >= 0 && v . get ( j ) > key ) { v . set ( j + 1 , v . get ( i ) ) ; j = j - 1 ; } v . set ( j + 1 , key ) ; } } static void inorder ( node root , ArrayList < Integer > v ) { if ( root == null ) return ; inorder ( root . left , v ) ; v . add ( root . data ) ; inorder ( root . right , v ) ; } static void find ( node root , int res , int res2 ) { if ( root == null ) { return ; } find ( root . left , res , res2 ) ; if ( root . data == res ) { root . data = res2 ; } else if ( root . data == res2 ) { root . data = res ; } find ( root . right , res , res2 ) ; } static node correctBST ( node root ) { ArrayList < Integer > v = new ArrayList < > ( ) ; inorder ( root , v ) ; ArrayList < Integer > v1 = new ArrayList < > ( v ) ; insertionSort ( v , v . size ( ) ) ; for ( int i = 0 ; i < v . size ( ) ; i ++ ) { if ( v . get ( i ) != v1 . get ( i ) ) { find ( root , v1 . get ( i ) , v . get ( i ) ) ; break ; } } return root ; } static void printInorder ( node node ) { if ( node == null ) return ; printInorder ( node . left ) ; System . out . printf ( " % d ▁ " , node . data ) ; printInorder ( node . right ) ; } public static void main ( String [ ] args ) { node root = new node ( 6 ) ; root . left = new node ( 10 ) ; root . right = new node ( 2 ) ; root . left . left = new node ( 1 ) ; root . left . right = new node ( 3 ) ; root . right . right = new node ( 12 ) ; root . right . left = new node ( 7 ) ; System . out . printf ( " Inorder ▁ Traversal ▁ of ▁ the " ) ; System . out . printf ( "original tree NEW_LINE"); printInorder ( root ) ; correctBST ( root ) ; System . out . printf ( " Inorder Traversal of the "); System . out . printf ( "fixed tree NEW_LINE"); printInorder ( root ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG, node
Java program:
class GFG { static class Node { int data ; Node next ; } ; static Node newNode ( int val ) { Node temp = new Node ( ) ; temp . data = val ; temp . next = null ; return temp ; } static Node selectionSort ( Node head ) { Node a , b , c , d , r ; a = b = head ; while ( b . next != null ) { c = d = b . next ; while ( d != null ) { if ( b . data > d . data ) { if ( b . next == d ) { if ( b == head ) { b . next = d . next ; d . next = b ; r = b ; b = d ; d = r ; c = d ; head = b ; d = d . next ; } else { b . next = d . next ; d . next = b ; a . next = d ; r = b ; b = d ; d = r ; c = d ; d = d . next ; } } else { if ( b == head ) { r = b . next ; b . next = d . next ; d . next = r ; c . next = b ; r = b ; b = d ; d = r ; c = d ; d = d . next ; head = b ; } else { r = b . next ; b . next = d . next ; d . next = r ; c . next = b ; a . next = d ; r = b ; b = d ; d = r ; c = d ; d = d . next ; } } } else { c = d ; d = d . next ; } } a = b ; b = b . next ; } return head ; } static void printList ( Node head ) { while ( head != null ) { System . out . print ( head . data + " ▁ " ) ; head = head . next ; } } public static void main ( String args [ ] ) { Node head = newNode ( 5 ) ; head . next = newNode ( 4 ) ; head . next . next = newNode ( 3 ) ; head = selectionSort ( head ) ; printList ( head ) ; } }

Class/struct names: GFG, Node
Java program:
import java . util . Arrays ; class GFG { static void printArr ( int arr [ ] , int n ) { for ( int i = 0 ; i < n ; i ++ ) { System . out . print ( arr [ i ] + " ▁ " ) ; } } static void findNumbers ( int arr [ ] , int n ) { Arrays . sort ( arr ) ; reverse ( arr ) ; int freq [ ] = new int [ arr [ 0 ] + 1 ] ; for ( int i = 0 ; i < n ; i ++ ) { freq [ arr [ i ] ] ++ ; } int size = ( int ) Math . sqrt ( n ) ; int brr [ ] = new int [ size ] , x , l = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( freq [ arr [ i ] ] > 0 && l < size ) { brr [ l ] = arr [ i ] ; freq [ brr [ l ] ] -- ; l ++ ; for ( int j = 0 ; j < l ; j ++ ) { if ( i != j ) { x = __gcd ( arr [ i ] , brr [ j ] ) ; freq [ x ] -= 2 ; } } } } printArr ( brr , size ) ; } public static void reverse ( int [ ] input ) { int last = input . length - 1 ; int middle = input . length / 2 ; for ( int i = 0 ; i <= middle ; i ++ ) { int temp = input [ i ] ; input [ i ] = input [ last - i ] ; input [ last - i ] = temp ; } } static int __gcd ( int a , int b ) { if ( b == 0 ) { return a ; } return __gcd ( b , a % b ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 5 , 5 , 5 , 7 , 10 , 12 , 2 , 2 } ; int n = arr . length ; findNumbers ( arr , n ) ; } }

Index/key variables: i, j, l, size, x
Accumulator variables: i, j, l
Iterator variables: i, j
Class/struct names: GFG
Java program:
class GfG { static String strBitwiseAND ( String [ ] arr , int n ) { String res = " " ; int smallest_size = Integer . MAX_VALUE ; int largest_size = Integer . MIN_VALUE ; for ( int i = 0 ; i < n ; i ++ ) { StringBuilder temp = new StringBuilder ( ) ; temp . append ( arr [ i ] ) ; arr [ i ] = temp . reverse ( ) . toString ( ) ; smallest_size = Math . min ( smallest_size , arr [ i ] . length ( ) ) ; largest_size = Math . max ( largest_size , arr [ i ] . length ( ) ) ; } for ( int i = 0 ; i < smallest_size ; i ++ ) { boolean all_ones = true ; for ( int j = 0 ; j < n ; j ++ ) { if ( arr [ j ] . charAt ( i ) == '0' ) { all_ones = false ; break ; } } res += ( all_ones ? '1' : '0' ) ; } for ( int i = 0 ; i < largest_size - smallest_size ; i ++ ) res += '0' ; StringBuilder temp = new StringBuilder ( ) ; temp . append ( res ) ; res = temp . reverse ( ) . toString ( ) ; return res ; } public static void main ( String [ ] args ) { String arr [ ] = { "101" , "110110" , "111" } ; int n = arr . length ; System . out . println ( strBitwiseAND ( arr , n ) ) ; } }

Index/key variables: i, j
Accumulator variables: i, j, res
Iterator variables: i, j
Boolean variables: all_ones
Class/struct names: GfG
Java program:
import java . io . * ; import java . util . * ; class Graph { private static void printPath ( List < Integer > path ) { int size = path . size ( ) ; for ( Integer v : path ) { System . out . print ( v + " ▁ " ) ; } System . out . println ( ) ; } private static boolean isNotVisited ( int x , List < Integer > path ) { int size = path . size ( ) ; for ( int i = 0 ; i < size ; i ++ ) if ( path . get ( i ) == x ) return false ; return true ; } private static void findpaths ( List < List < Integer > > g , int src , int dst , int v ) { Queue < List < Integer > > queue = new LinkedList < > ( ) ; List < Integer > path = new ArrayList < > ( ) ; path . add ( src ) ; queue . offer ( path ) ; while ( ! queue . isEmpty ( ) ) { path = queue . poll ( ) ; int last = path . get ( path . size ( ) - 1 ) ; if ( last == dst ) { printPath ( path ) ; } List < Integer > lastNode = g . get ( last ) ; for ( int i = 0 ; i < lastNode . size ( ) ; i ++ ) { if ( isNotVisited ( lastNode . get ( i ) , path ) ) { List < Integer > newpath = new ArrayList < > ( path ) ; newpath . add ( lastNode . get ( i ) ) ; queue . offer ( newpath ) ; } } } } public static void main ( String [ ] args ) { List < List < Integer > > g = new ArrayList < > ( ) ; int v = 4 ; for ( int i = 0 ; i < 4 ; i ++ ) { g . add ( new ArrayList < > ( ) ) ; } g . get ( 0 ) . add ( 3 ) ; g . get ( 0 ) . add ( 1 ) ; g . get ( 0 ) . add ( 2 ) ; g . get ( 1 ) . add ( 3 ) ; g . get ( 2 ) . add ( 0 ) ; g . get ( 2 ) . add ( 1 ) ; int src = 2 , dst = 3 ; System . out . println ( " path ▁ from ▁ src ▁ " + src + " ▁ to ▁ dst ▁ " + dst + " ▁ are ▁ " ) ; findpaths ( g , src , dst , v ) ; } }

Accumulator variables: i
Iterator variables: i, v
Class/struct names: Graph
Java program:
import java . util . * ; class GFG { static void AlternateRearrange ( int arr [ ] , int n ) { Arrays . sort ( arr ) ; for ( int i = 0 ; i < n ; i ++ ) if ( arr [ i ] % 2 == 0 ) v1 . add ( arr [ i ] ) ; else v2 . add ( arr [ i ] ) ; int index = 0 , i = 0 , j = 0 ; boolean flag = false ; if ( arr [ 0 ] % 2 == 0 ) flag = true ; while ( index < n ) { if ( flag == true ) { arr [ index ] = ( int ) v1 . get ( i ) ; i += 1 ; index += 1 ; flag = ! flag ; } else { arr [ index ] = ( int ) v2 . get ( j ) ; j += 1 ; index += 1 ; flag = ! flag ; } } for ( i = 0 ; i < n ; i ++ ) System . out . print ( arr [ i ] + " ▁ " ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 9 , 8 , 13 , 2 , 19 , 14 } ; int n = arr . length ; AlternateRearrange ( arr , n ) ; } }

Index/key variables: i, index
Accumulator variables: i, index, j
Iterator variables: i
Boolean variables: flag
Class/struct names: GFG
Java program:
import java . util . * ; public class GFG { static int getNumToAdd ( int arr [ ] , int n ) { Arrays . sort ( arr ) ; int d = arr [ 1 ] - arr [ 0 ] ; int numToAdd = - 1 ; boolean numAdded = false ; for ( int i = 2 ; i < n ; i ++ ) { int diff = arr [ i ] - arr [ i - 1 ] ; if ( diff != d ) { if ( numAdded ) return - 1 ; if ( diff == 2 * d ) { numToAdd = arr [ i ] - d ; numAdded = true ; } else return - 1 ; } } if ( numToAdd == - 1 ) return ( arr [ n - 1 ] + d ) ; return numToAdd ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 3 , 5 , 7 , 11 , 13 , 15 } ; int n = arr . length ; System . out . println ( getNumToAdd ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Boolean variables: numAdded
Class/struct names: GFG
Java program:
import java . util . * ; import java . awt . Point ; public class Main { static int Minimum_Cells ( Vector < Point > v ) { int [ ] col = new int [ 3 ] ; int i , j ; for ( i = 0 ; i < 3 ; i ++ ) { int column_number = v . get ( i ) . y ; col [ i ] = column_number ; } Arrays . sort ( col ) ; int MidRow = v . get ( 1 ) . x ; Set < Point > s = new HashSet < Point > ( ) ; int Maxcol = col [ 2 ] , MinCol = col [ 0 ] ; for ( i = MinCol ; i <= Maxcol ; i ++ ) { s . add ( new Point ( MidRow , i ) ) ; } for ( i = 0 ; i < 3 ; i ++ ) { if ( v . get ( i ) . x == MidRow ) continue ; for ( j = Math . min ( v . get ( i ) . x , MidRow ) ; j <= Math . max ( v . get ( i ) . x , MidRow ) ; j ++ ) { s . add ( new Point ( j , v . get ( i ) . x ) ) ; } } return s . size ( ) ; } public static void main ( String [ ] args ) { Vector < Point > v = new Vector < Point > ( ) ; v . add ( new Point ( 0 , 0 ) ) ; v . add ( new Point ( 1 , 1 ) ) ; v . add ( new Point ( 2 , 2 ) ) ; System . out . print ( Minimum_Cells ( v ) ) ; } }

Index/key variables: i
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: Main
Java program:
import java . util . Arrays ; import java . io . * ; class GFG { static int items ( int n , int a [ ] ) { Arrays . sort ( a ) ; int z = a [ n - 1 ] ; int x = 1 ; int s = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { s += a [ i ] ; if ( s <= z ) x += 1 ; else break ; } return x ; } public static void main ( String [ ] args ) { int n = 5 ; int a [ ] = { 5 , 3 , 1 , 5 , 6 } ; System . out . println ( items ( n , a ) ) ; } }

Index/key variables: i
Accumulator variables: i, s, x
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class Node { static void sortWithSetbits ( int arr [ ] , int n , int k ) { Vector < Integer > v1 = new Vector < > ( ) , v2 = new Vector < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( Integer . bitCount ( arr [ i ] ) == k ) { v1 . add ( i ) ; v2 . add ( arr [ i ] ) ; } } Collections . sort ( v2 ) ; for ( int i = 0 ; i < v1 . size ( ) ; i ++ ) { arr [ v1 . get ( i ) ] = v2 . get ( i ) ; } for ( int i = 0 ; i < n ; i ++ ) { System . out . print ( arr [ i ] + " ▁ " ) ; } } public static void main ( String [ ] args ) { int arr [ ] = { 14 , 255 , 1 , 7 , 13 } ; int n = arr . length ; int k = 3 ; sortWithSetbits ( arr , n , k ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: Node
Java program:
import java . util . * ; class solution { static int numBoxes ( int A [ ] , int n , int K ) { Arrays . sort ( A ) ; int i = 0 , j = n - 1 ; int ans = 0 ; while ( i <= j ) { ans ++ ; if ( A [ i ] + A [ j ] <= K ) i ++ ; j -- ; } return ans ; } public static void main ( String args [ ] ) { int A [ ] = { 3 , 2 , 2 , 1 } , K = 3 ; int n = A . length ; System . out . println ( numBoxes ( A , n , K ) ) ; } }

Index/key variables: i, j
Accumulator variables: ans, i, j
Class/struct names: solution
Java program:
import java . io . * ; import java . util . * ; class Node { int data ; Node next , prev ; } class GFG { static int countTriplets ( Node head , int x ) { Node ptr , ptr1 , ptr2 ; int count = 0 ; Map < Integer , Node > um = new HashMap < Integer , Node > ( ) ; for ( ptr = head ; ptr != null ; ptr = ptr . next ) { um . put ( ptr . data , ptr ) ; } for ( ptr1 = head ; ptr1 != null ; ptr1 = ptr1 . next ) { for ( ptr2 = ptr1 . next ; ptr2 != null ; ptr2 = ptr2 . next ) { int p_product = ( ptr1 . data * ptr2 . data ) ; if ( um . containsKey ( x / p_product ) && um . get ( x / p_product ) != ptr1 && um . get ( x / p_product ) != ptr2 ) { count ++ ; } } } return ( count / 3 ) ; } static Node insert ( Node head , int data ) { Node temp = new Node ( ) ; temp . data = data ; temp . next = temp . prev = null ; if ( head == null ) { head = temp ; } else { temp . next = head ; head . prev = temp ; head = temp ; } return head ; } public static void main ( String [ ] args ) { Node head = null ; head = insert ( head , 9 ) ; head = insert ( head , 8 ) ; head = insert ( head , 6 ) ; head = insert ( head , 5 ) ; head = insert ( head , 4 ) ; head = insert ( head , 2 ) ; head = insert ( head , 1 ) ; int x = 8 ; System . out . println ( " Count ▁ = ▁ " + countTriplets ( head , x ) ) ; } }

Accumulator variables: count
Iterator variables: ptr, ptr1, ptr2
Class/struct names: GFG, Node
Java program:
import java . util . * ; import java . lang . * ; import java . io . * ; class GFG { static int solve ( int N , int M , int cp [ ] , int sp [ ] ) { Integer [ ] profit = new Integer [ N ] ; for ( int i = 0 ; i < N ; i ++ ) profit [ i ] = sp [ i ] - cp [ i ] ; Arrays . sort ( profit , Collections . reverseOrder ( ) ) ; int sum = 0 ; for ( int i = 0 ; i < M ; i ++ ) { if ( profit [ i ] > 0 ) sum += profit [ i ] ; else break ; } return sum ; } public static void main ( String args [ ] ) { int N = 5 , M = 3 ; int CP [ ] = { 5 , 10 , 35 , 7 , 23 } ; int SP [ ] = { 11 , 10 , 0 , 9 , 19 } ; System . out . println ( solve ( N , M , CP , SP ) ) ; } }

Index/key variables: N, i
Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
Java program:
import java . * ; import java . util . Arrays ; class GFG { static int findMaxNum ( int arr [ ] , int n ) { Arrays . sort ( arr ) ; int num = arr [ 0 ] ; for ( int i = n - 1 ; i >= 0 ; i -- ) { num = num * 10 + arr [ i ] ; } return num ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 3 , 4 , 5 , 0 } ; int n = arr . length ; System . out . println ( findMaxNum ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . Arrays ; class GFG { static int minimumSets ( int arr [ ] , int n , int key ) { int i , j ; Arrays . sort ( arr ) ; for ( i = 0 , j = n - 1 ; i <= j ; ++ i ) if ( arr [ i ] + arr [ j ] <= key ) j -- ; return i ; } public static void main ( String [ ] args ) { int [ ] arr = { 3 , 5 , 3 , 4 } ; int n = arr . length ; int key = 5 ; System . out . println ( minimumSets ( arr , n , key ) ) ; } }

Index/key variables: i, j
Accumulator variables: j
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static class Node { int data ; Node prev ; Node next ; } ; static Node insertAtTheBegin ( Node start_ref , int data ) { Node ptr1 = new Node ( ) ; ptr1 . data = data ; ptr1 . next = start_ref ; if ( start_ref != null ) ( start_ref ) . prev = ptr1 ; start_ref = ptr1 ; return start_ref ; } static void printList ( Node start ) { Node temp = start ; System . out . println ( ) ; while ( temp != null ) { System . out . print ( temp . data + " ▁ " ) ; temp = temp . next ; } } static Node bubbleSort ( Node start ) { int swapped , i ; Node ptr1 ; Node lptr = null ; if ( start == null ) return null ; do { swapped = 0 ; ptr1 = start ; while ( ptr1 . next != lptr ) { if ( ptr1 . data > ptr1 . next . data ) { int t = ptr1 . data ; ptr1 . data = ptr1 . next . data ; ptr1 . next . data = t ; swapped = 1 ; } ptr1 = ptr1 . next ; } lptr = ptr1 ; } while ( swapped != 0 ) ; return start ; } public static void main ( String args [ ] ) { int arr [ ] = { 12 , 56 , 2 , 11 , 1 , 90 } ; int list_size , i ; Node start = null ; for ( i = 0 ; i < 6 ; i ++ ) start = insertAtTheBegin ( start , arr [ i ] ) ; System . out . printf ( " Linked list before sorting "); printList ( start ) ; start = bubbleSort ( start ) ; System . out . printf ( " Linked list after sorting "); printList ( start ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG, Node
Java program:
import java . util . Arrays ; public class Demo { public static void substringSort ( String [ ] arr , int n , int maxLen ) { int count [ ] = new int [ maxLen ] ; String [ ] sortedArr = new String [ maxLen ] ; Arrays . fill ( count , 0 ) ; Arrays . fill ( sortedArr , " " ) ; for ( int i = 0 ; i < n ; i ++ ) { String s = arr [ i ] ; int len = s . length ( ) ; if ( count [ len - 1 ] == 0 ) { sortedArr [ len - 1 ] = s ; count [ len - 1 ] = 1 ; } else if ( sortedArr [ len - 1 ] . equals ( s ) ) { count [ len - 1 ] ++ ; } else { System . out . println ( " Cannot ▁ be ▁ sorted " ) ; return ; } } int index = 0 ; while ( count [ index ] == 0 ) index ++ ; int prev = index ; String prevString = sortedArr [ prev ] ; index ++ ; for ( ; index < maxLen ; index ++ ) { if ( count [ index ] != 0 ) { String current = sortedArr [ index ] ; if ( current . contains ( prevString ) ) { prev = index ; prevString = current ; } else { System . out . println ( " Cannot ▁ be ▁ sorted " ) ; return ; } } } for ( int i = 0 ; i < maxLen ; i ++ ) { String s = sortedArr [ i ] ; for ( int j = 0 ; j < count [ i ] ; j ++ ) { System . out . println ( s ) ; } } } public static void main ( String [ ] args ) { int maxLen = 100 ; String [ ] arr1 = { " d " , " zddsaaz " , " ds " , " ddsaa " , " dds " , " dds " } ; substringSort ( arr1 , arr1 . length , maxLen ) ; String [ ] arr2 = { " for " , " rof " } ; substringSort ( arr2 , arr2 . length , maxLen ) ; } }

Index/key variables: i, index, maxLen, prev
Accumulator variables: i, index, j
Iterator variables: i, j
Class/struct names: Demo