dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
import java . util . * ; class GFG { static int [ ] [ ] dp = new int [ 1000 ] [ 1000 ] ; static int minimumIncDec ( int arr [ ] , int N , int maxE , int minE ) { if ( N == 0 ) { return 0 ; } if ( dp [ N ] [ maxE ] != 0 ) return dp [ N ] [ maxE ] ; int ans = Integer . MAX_VALUE ; for ( int k = minE ; k <= maxE ; k ++ ) { int x = minimumIncDec ( arr , N - 1 , k , minE ) ; ans = Math . min ( ans , x + Math . abs ( arr [ N - 1 ] - k ) ) ; } dp [ N ] [ maxE ] = ans ; return dp [ N ] [ maxE ] ; } public static void main ( String [ ] args ) { int arr [ ] = { 5 , 4 , 3 , 2 , 1 } ; int N = arr . length ; int minE = Arrays . stream ( arr ) . min ( ) . getAsInt ( ) ; int maxE = Arrays . stream ( arr ) . max ( ) . getAsInt ( ) ; System . out . print ( minimumIncDec ( arr , N , maxE , minE ) ) ; } }

Index/key variables: N, maxE
Accumulator variables: k
Iterator variables: k
Class/struct names: GFG
Java program:
class GFG { static void sortDiagonal ( int a [ ] [ ] , int M , int N ) { for ( int i = 0 ; i < M ; i ++ ) { int sm = a [ i ] [ i ] ; int pos = i ; for ( int j = i + 1 ; j < N ; j ++ ) { if ( sm > a [ j ] [ j ] ) { sm = a [ j ] [ j ] ; pos = j ; } } swap ( a , i , i , pos , pos ) ; } for ( int i = 0 ; i < M ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) System . out . print ( a [ i ] [ j ] + " ▁ " ) ; System . out . println ( ) ; } } static void swap ( int [ ] [ ] a , int i , int i2 , int pos , int pos2 ) { int temp = a [ i ] [ i2 ] ; a [ i ] [ i2 ] = a [ pos ] [ pos2 ] ; a [ pos ] [ pos2 ] = temp ; } public static void main ( String [ ] args ) { int a [ ] [ ] = { { 4 , 2 } , { 3 , 1 } } ; sortDiagonal ( a , 2 , 2 ) ; } }

Index/key variables: i, i2, j, pos, pos2
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int make_permutation ( int arr [ ] , int n ) { Arrays . sort ( arr ) ; int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) ans += Math . abs ( i + 1 - arr [ i ] ) ; return ans ; } public static void main ( String [ ] args ) { int arr [ ] = { 5 , 3 , 8 , 1 , 1 } ; int n = arr . length ; System . out . print ( make_permutation ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: ans, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; import java . lang . * ; import java . io . * ; class GFG { static int maxSum ( int [ ] [ ] V , int n , int m ) { int ans = 0 ; for ( int i = n - 2 ; i >= 0 ; -- i ) { ArrayList < int [ ] > aux = new ArrayList < > ( ) ; for ( int j = 0 ; j < m ; ++ j ) { aux . add ( new int [ ] { V [ i + 1 ] [ j ] , j } ) ; } Collections . sort ( aux , ( a , b ) -> b [ 0 ] - a [ 0 ] ) ; for ( int j = 0 ; j < m ; ++ j ) { for ( int k = 0 ; k < m ; ++ k ) { if ( aux . get ( k ) [ 1 ] - j == 0 || Math . abs ( aux . get ( k ) [ 1 ] - j ) > 1 ) { V [ i ] [ j ] += aux . get ( k ) [ 0 ] ; break ; } } } } for ( int i = 0 ; i < m ; ++ i ) { ans = Math . max ( ans , V [ 0 ] [ i ] ) ; } return ans ; } public static void main ( String [ ] args ) { int [ ] [ ] V = { { 1 , 2 , 3 , 4 } , { 8 , 7 , 6 , 5 } , { 10 , 11 , 12 , 13 } } ; int n = V . length ; int m = V [ 0 ] . length ; System . out . println ( maxSum ( V , n , m ) ) ; } }

Index/key variables: i, j
Iterator variables: i, j, k
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int minimumProduct ( int [ ] arr , int n ) { Arrays . sort ( arr ) ; int product = 1 ; for ( int i = 0 ; i < n ; i += 2 ) { product *= ( arr [ i ] + arr [ i + 1 ] ) ; } return product ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 6 , 3 , 1 , 7 , 8 } ; int n = arr . length ; System . out . print ( minimumProduct ( arr , n ) + "NEW_LINE"); } }

Index/key variables: i
Accumulator variables: i, product
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static boolean checkIsAP ( double arr [ ] , int n ) { if ( n == 1 ) return true ; Arrays . sort ( arr ) ; double d = arr [ 1 ] - arr [ 0 ] ; for ( int i = 2 ; i < n ; i ++ ) { if ( arr [ i ] - arr [ i - 1 ] != d ) { return false ; } } return true ; } static boolean checkIsGP ( double arr [ ] , int n ) { if ( n == 1 ) return true ; Arrays . sort ( arr ) ; double r = arr [ 1 ] / arr [ 0 ] ; for ( int i = 2 ; i < n ; i ++ ) { if ( arr [ i ] / arr [ i - 1 ] != r ) return false ; } return true ; } static boolean checkIsHP ( double arr [ ] , int n ) { if ( n == 1 ) { return true ; } double [ ] rec = new double [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { rec [ i ] = ( ( 1 / arr [ i ] ) ) ; } if ( checkIsAP ( rec , n ) ) return true ; else return false ; } public static void main ( String [ ] args ) { double arr [ ] = { 1.0 / 5.0 , 1.0 / 10.0 , 1.0 / 15.0 , 1.0 / 20.0 } ; int n = arr . length ; int flag = 0 ; if ( checkIsAP ( arr , n ) ) { System . out . print ( " Yes , ▁ An ▁ AP ▁ can ▁ be ▁ formed " + "NEW_LINE"); flag = 1 ; } if ( checkIsGP ( arr , n ) ) { System . out . print ( " Yes , ▁ A ▁ GP ▁ can ▁ be ▁ formed " + "NEW_LINE"); flag = 1 ; } if ( checkIsHP ( arr , n ) ) { System . out . print ( " Yes , ▁ A ▁ HP ▁ can ▁ be ▁ formed " + "NEW_LINE"); flag = 1 ; } else if ( flag == 0 ) { System . out . print ( " No " ) ; } } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; import java . lang . * ; import java . io . * ; class GFG { static int reversDigits ( int num ) { int rev_num = 0 ; while ( num > 0 ) { rev_num = rev_num * 10 + num % 10 ; num = num / 10 ; } return rev_num ; } static void sortArr ( int arr [ ] , int n ) { ArrayList < int [ ] > vp = new ArrayList < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { vp . add ( new int [ ] { reversDigits ( arr [ i ] ) , arr [ i ] } ) ; } Collections . sort ( vp , ( a , b ) -> a [ 0 ] - b [ 0 ] ) ; for ( int i = 0 ; i < vp . size ( ) ; i ++ ) System . out . print ( vp . get ( i ) [ 1 ] + " ▁ " ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 12 , 10 , 102 , 31 , 15 } ; int n = arr . length ; sortArr ( arr , n ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static void sortMat ( int [ ] [ ] data , int row , int col ) { int size = row * col ; for ( int i = 0 ; i < size ; i ++ ) { for ( int j = 0 ; j < size - 1 ; j ++ ) { if ( data [ j / col ] [ j % col ] > data [ ( j + 1 ) / col ] [ ( j + 1 ) % col ] ) { int temp = data [ j / col ] [ j % col ] ; data [ j / col ] [ j % col ] = data [ ( j + 1 ) / col ] [ ( j + 1 ) % col ] ; data [ ( j + 1 ) / col ] [ ( j + 1 ) % col ] = temp ; } } } } static void printMat ( int [ ] [ ] mat , int row , int col ) { for ( int i = 0 ; i < row ; i ++ ) { for ( int j = 0 ; j < col ; j ++ ) { System . out . print ( mat [ i ] [ j ] + " ▁ " ) ; } System . out . println ( ) ; } } public static void main ( String [ ] args ) { int [ ] [ ] mat = { { 5 , 4 , 7 } , { 1 , 3 , 8 } , { 2 , 9 , 6 } } ; int row = mat . length ; int col = mat [ 0 ] . length ; sortMat ( mat , row , col ) ; printMat ( mat , row , col ) ; } }

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 minimiseMedian ( int arr [ ] , int n ) { Arrays . sort ( arr ) ; return Math . abs ( arr [ n / 2 ] - arr [ ( n / 2 ) - 1 ] ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 15 , 25 , 35 , 50 } ; int n = arr . length ; System . out . println ( minimiseMedian ( arr , n ) ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; import java . lang . * ; import java . io . * ; class GFG { static class pair { int first ; char second ; pair ( int first , char second ) { this . first = first ; this . second = second ; } } static void overlap ( int [ ] [ ] v ) { int ans = 0 ; int count = 0 ; ArrayList < pair > data = new ArrayList < > ( ) ; for ( int i = 0 ; i < v . length ; i ++ ) { data . add ( new pair ( v [ i ] [ 0 ] , ' x ' ) ) ; data . add ( new pair ( v [ i ] [ 1 ] , ' y ' ) ) ; } Collections . sort ( data , ( a , b ) -> a . first - b . first ) ; for ( int i = 0 ; i < data . size ( ) ; i ++ ) { if ( data . get ( i ) . second == ' x ' ) count ++ ; if ( data . get ( i ) . second == ' y ' ) count -- ; ans = Math . max ( ans , count ) ; } System . out . println ( ans ) ; } public static void main ( String [ ] args ) { int [ ] [ ] v = { { 1 , 2 } , { 2 , 4 } , { 3 , 6 } } ; overlap ( v ) ; } }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG, pair
Java program:
import java . util . * ; class GFG { static boolean canBeEqual ( int a , int b , int c , int k ) { int [ ] arr = new int [ 3 ] ; arr [ 0 ] = a ; arr [ 1 ] = b ; arr [ 2 ] = c ; Arrays . sort ( arr ) ; int diff = 2 * arr [ 2 ] - arr [ 1 ] - arr [ 0 ] ; k = k - diff ; if ( k < 0 k % 3 != 0 ) return false ; return true ; } public static void main ( String [ ] args ) { int a1 = 6 , b1 = 3 , c1 = 2 , k1 = 7 ; if ( canBeEqual ( a1 , b1 , c1 , k1 ) ) System . out . print ( " Yes " ) ; else System . out . print ( " No " ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int [ ] orgazineInOrder ( int [ ] vec , int [ ] op , int n ) { int [ ] result = new int [ n ] ; Arrays . sort ( vec ) ; int i = 0 , j = n - 1 , k = 0 ; while ( i <= j && k <= n - 2 ) { if ( op [ k ] == ' < ' ) { result [ k ] = vec [ i ++ ] ; } else { result [ k ] = vec [ j -- ] ; } k ++ ; } result [ n - 1 ] = vec [ i ] ; return result ; } public static void main ( String [ ] args ) { int [ ] vec = { 8 , 2 , 7 , 1 , 5 , 9 } ; int [ ] op = { ' > ' , ' > ' , ' < ' , ' > ' , ' < ' } ; int [ ] result = orgazineInOrder ( vec , op , vec . length ) ; for ( int i = 0 ; i < result . length ; i ++ ) { System . out . print ( result [ i ] + " ▁ " ) ; } } }

Index/key variables: i, k, n
Accumulator variables: i, j, k
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int findSum ( int [ ] arr , int n , int k ) { int ans = arr [ n - k - 1 ] - arr [ 0 ] ; for ( int i = 1 ; i <= k ; i ++ ) { ans = Math . min ( arr [ n - 1 - ( k - i ) ] - arr [ i ] , ans ) ; } return ans ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 100 , 120 , 140 } ; int k = 2 ; int n = arr . length ; System . out . println ( findSum ( arr , n , k ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int findMin ( int arr [ ] , int n ) { int ans = 1 ; for ( int i = 0 ; i < n ; i ++ ) { int j = i + 1 ; while ( j < n && arr [ j ] >= arr [ j - 1 ] ) j ++ ; ans = Math . max ( ans , j - i ) ; i = j - 1 ; } return n - ans ; } public static void main ( String [ ] args ) { int arr [ ] = { 3 , 2 , 1 } ; int n = arr . length ; System . out . println ( findMin ( arr , n ) ) ; } }

Index/key variables: j
Accumulator variables: i, j
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int countSubSeq ( int a [ ] , int n , int k ) { Arrays . sort ( a ) ; List < Integer > arr = new LinkedList < > ( ) ; for ( int i = 0 ; i < n ; ) { int count = 1 , x = a [ i ] ; i ++ ; while ( i < n && a [ i ] == x ) { count ++ ; i ++ ; } arr . add ( count ) ; } int m = arr . size ( ) ; n = Math . min ( m , k ) ; int count = 1 ; int [ ] [ ] dp = new int [ n + 1 ] [ m + 1 ] ; for ( int i = 0 ; i <= m ; i ++ ) dp [ 0 ] [ i ] = 1 ; for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = m ; j >= 0 ; j -- ) { if ( j > m - i ) dp [ i ] [ j ] = 0 ; else { dp [ i ] [ j ] = dp [ i ] [ j + 1 ] + arr . get ( j ) * dp [ i - 1 ] [ j + 1 ] ; } } count = count + dp [ i ] [ 0 ] ; } return count ; } public static void main ( String [ ] args ) { int a [ ] = { 2 , 2 , 3 , 3 , 5 } ; int n = a . length ; int k = 3 ; System . out . println ( countSubSeq ( a , n , k ) ) ; } }

Index/key variables: i, j
Accumulator variables: count, i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . LinkedList ; import java . util . Queue ; class GFG { public static int countUnvisited ( int n , int m ) { int X = ( m * n ) - m - n ; Queue < Integer > queue = new LinkedList < > ( ) ; queue . add ( X ) ; int count = 0 ; while ( ! queue . isEmpty ( ) ) { int curr = queue . poll ( ) ; count ++ ; if ( curr - m > 0 ) queue . add ( curr - m ) ; if ( curr - n > 0 ) queue . add ( curr - n ) ; } return count ; } public static void main ( String args [ ] ) { int n = 2 , m = 5 ; System . out . print ( countUnvisited ( n , m ) ) ; } }

Accumulator variables: count
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static String partOdd ( String s ) { String st = " " ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( i % 2 != 0 ) st += s . charAt ( i ) ; } return st ; } static String partEven ( String str ) { String s = " " ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { if ( i % 2 == 0 ) s += str . charAt ( i ) ; } return s ; } static boolean canBeMadeEqual ( String s1 , String s2 ) { char [ ] even1 = partEven ( s1 ) . toCharArray ( ) ; char [ ] even2 = partEven ( s2 ) . toCharArray ( ) ; char [ ] odd1 = partOdd ( s1 ) . toCharArray ( ) ; char [ ] odd2 = partOdd ( s2 ) . toCharArray ( ) ; Arrays . sort ( even1 ) ; Arrays . sort ( even2 ) ; Arrays . sort ( odd1 ) ; Arrays . sort ( odd2 ) ; String even_s1 = new String ( even1 ) ; String even_s2 = new String ( even2 ) ; String odd_s1 = new String ( odd1 ) ; String odd_s2 = new String ( odd2 ) ; if ( even_s1 . equals ( even_s2 ) && odd_s1 . equals ( odd_s2 ) ) return true ; return false ; } public static void main ( String [ ] args ) { String s1 = " cdab " ; String s2 = " abcd " ; if ( canBeMadeEqual ( s1 , s2 ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } }

Accumulator variables: i, s, st
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { static void sortStack ( Stack < Integer > input , int k ) { Stack < Integer > tmpStack = new Stack < Integer > ( ) ; while ( ! input . isEmpty ( ) ) { int tmp = input . peek ( ) ; input . pop ( ) ; while ( ! tmpStack . isEmpty ( ) ) { int tmpStackMod = tmpStack . peek ( ) % k ; int tmpMod = tmp % k ; if ( ( tmpStackMod > tmpMod ) || ( tmpStackMod == tmpMod && tmpStack . peek ( ) > tmp ) ) { input . push ( tmpStack . peek ( ) ) ; tmpStack . pop ( ) ; } else break ; } tmpStack . push ( tmp ) ; } while ( ! tmpStack . isEmpty ( ) ) { input . push ( tmpStack . peek ( ) ) ; tmpStack . pop ( ) ; } while ( ! input . empty ( ) ) { System . out . print ( input . peek ( ) + " ▁ " ) ; input . pop ( ) ; } } public static void main ( String args [ ] ) { Stack < Integer > input = new Stack < Integer > ( ) ; input . push ( 10 ) ; input . push ( 3 ) ; input . push ( 2 ) ; input . push ( 6 ) ; input . push ( 12 ) ; int k = 4 ; sortStack ( input , k ) ; } }

Class/struct names: GFG
Java program:
class GFG { static int MAX = 1000 ; static boolean lineExists ( int x [ ] , int y [ ] , int v [ ] , int n ) { int size = ( 2 * MAX ) + 1 ; long [ ] arr = new long [ size ] ; for ( int i = 0 ; i < n ; i ++ ) { arr [ x [ i ] + MAX ] += v [ i ] ; } for ( int i = 1 ; i < size ; i ++ ) arr [ i ] += arr [ i - 1 ] ; if ( arr [ size - 1 ] == 0 ) return true ; if ( arr [ size - 1 ] - arr [ 0 ] == 0 ) return true ; for ( int i = 1 ; i < size - 1 ; i ++ ) { if ( arr [ i - 1 ] == arr [ size - 1 ] - arr [ i - 1 ] ) return true ; if ( arr [ i - 1 ] == arr [ size - 1 ] - arr [ i ] ) return true ; if ( arr [ i ] == arr [ size - 1 ] - arr [ i ] ) return true ; } if ( arr [ size - 2 ] == 0 ) return true ; return false ; } public static void main ( String [ ] args ) { int x [ ] = { - 3 , 5 , 8 } ; int y [ ] = { 8 , 7 , 9 } ; int v [ ] = { 8 , 2 , 10 } ; int n = x . length ; if ( lineExists ( x , y , v , n ) ) System . out . printf ( " Yes " ) ; else System . out . printf ( " No " ) ; } }

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

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void printArr ( int [ ] arr , int n ) { for ( int i = 0 ; i < n ; i ++ ) System . out . print ( arr [ i ] + " ▁ " ) ; } static void sortWithRemainder ( int [ ] arr , int n , int k ) { ArrayList < ArrayList < Integer > > v = new ArrayList < ArrayList < Integer > > ( k ) ; for ( int i = 0 ; i < k ; i ++ ) v . add ( new ArrayList < Integer > ( ) ) ; for ( int i = 0 ; i < n ; i ++ ) { int t = arr [ i ] % k ; v . get ( t ) . add ( arr [ i ] ) ; } for ( int i = 0 ; i < k ; i ++ ) { Collections . sort ( v . get ( i ) ) ; } int j = 0 ; for ( int i = 0 ; i < k ; i ++ ) { for ( int x : v . get ( i ) ) { arr [ j ] = x ; j ++ ; } } printArr ( arr , n ) ; } public static void main ( String [ ] args ) { int [ ] arr = { 10 , 7 , 2 , 6 , 12 , 3 , 33 , 46 } ; int n = arr . length ; int k = 4 ; sortWithRemainder ( arr , n , k ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, x
Class/struct names: GFG
Java program:
import java . util . * ; class Gfg { public static boolean customSort ( String s1 , String s2 ) { int count_a1 = 0 , count_b1 = 0 ; for ( int i = 0 ; i < s1 . length ( ) ; i ++ ) { if ( s1 . charAt ( i ) == ' a ' ) { count_a1 ++ ; } else { count_b1 ++ ; } } int count_a2 = 0 , count_b2 = 0 ; for ( int i = 0 ; i < s2 . length ( ) ; i ++ ) { if ( s2 . charAt ( i ) == ' a ' ) { count_a2 ++ ; } else { count_b2 ++ ; } } if ( count_a1 * count_b2 > count_b1 * count_a2 ) { return true ; } else { return false ; } } public static String concatenateStrings ( String S [ ] , int N ) { String str = " " ; for ( int i = 0 ; i < N ; i ++ ) { str += S [ i ] ; } return str ; } public static int getMaxScore ( String S [ ] , int N ) { Arrays . sort ( S ) ; String combined_string = concatenateStrings ( S , N ) ; int final_score = 0 , count_a = 0 ; for ( int i = 0 ; i < combined_string . length ( ) ; i ++ ) { if ( combined_string . charAt ( i ) == ' a ' ) { count_a ++ ; } else { final_score += count_a ; } } return final_score ; } public static void main ( String [ ] args ) { String S [ ] = { " aa " , " bb " , " aab " , " bab " } ; int N = S . length ; System . out . println ( getMaxScore ( S , N ) - 10 ) ; } }

Index/key variables: i
Accumulator variables: count_a, count_a1, count_a2, count_b1, count_b2, final_score, i, str
Iterator variables: i
Class/struct names: Gfg
Java program:
import java . util . Arrays ; class geeksforgeeks { static int minOperations ( int ar [ ] , int k ) { Arrays . sort ( ar ) ; int opsNeeded = 0 ; for ( int i = 0 ; i < k ; i ++ ) { opsNeeded += ar [ k - 1 ] - ar [ i ] ; } int ans = opsNeeded ; for ( int i = k ; i < ar . length ; i ++ ) { opsNeeded = opsNeeded - ( ar [ i - 1 ] - ar [ i - k ] ) ; opsNeeded += ( k - 1 ) * ( ar [ i ] - ar [ i - 1 ] ) ; ans = Math . min ( ans , opsNeeded ) ; } return ans ; } public static void main ( String [ ] args ) { int [ ] arr = { 3 , 1 , 9 , 100 } ; int n = arr . length ; int k = 3 ; System . out . printf ( " % d " , minOperations ( arr , k ) ) ; } }

Index/key variables: i
Accumulator variables: i, opsNeeded
Iterator variables: i
Class/struct names: geeksforgeeks
Java program:
class GFG { static int x = - 1 ; static String [ ] heap = new String [ 1000 ] ; static void heapForm ( String k ) { x ++ ; heap [ x ] = k ; int child = x ; String tmp ; int index = x / 2 ; while ( index >= 0 ) { if ( heap [ index ] . compareTo ( heap [ child ] ) > 0 ) { tmp = heap [ index ] ; heap [ index ] = heap [ child ] ; heap [ child ] = tmp ; child = index ; index = index / 2 ; } else { break ; } } } static void heapSort ( ) { int left1 , right1 ; while ( x >= 0 ) { String k ; k = heap [ 0 ] ; System . out . print ( k + " ▁ " ) ; heap [ 0 ] = heap [ x ] ; x = x - 1 ; String tmp ; int index = 0 ; int length = x ; left1 = 1 ; right1 = left1 + 1 ; while ( left1 <= length ) { if ( heap [ index ] . compareTo ( heap [ left1 ] ) <= 0 && heap [ index ] . compareTo ( heap [ right1 ] ) <= 0 ) { break ; } else { if ( heap [ left1 ] . compareTo ( heap [ right1 ] ) < 0 ) { tmp = heap [ index ] ; heap [ index ] = heap [ left1 ] ; heap [ left1 ] = tmp ; index = left1 ; } else { tmp = heap [ index ] ; heap [ index ] = heap [ right1 ] ; heap [ right1 ] = tmp ; index = right1 ; } } left1 = 2 * left1 ; right1 = left1 + 1 ; } } } static void sort ( String k [ ] , int n ) { for ( int i = 0 ; i < n ; i ++ ) { heapForm ( k [ i ] ) ; } heapSort ( ) ; } public static void main ( String [ ] args ) { String arr [ ] = { " banana " , " orange " , " apple " , " pineapple " , " berries " , " lichi " } ; int n = arr . length ; sort ( arr , n ) ; } }

Index/key variables: child, i, index, left1, right1, x
Accumulator variables: i, x
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int getNumber ( int n , int k ) { int [ ] arr = new int [ n ] ; int i = 0 ; int odd = 1 ; while ( odd <= n ) { arr [ i ++ ] = odd ; odd += 2 ; } int even = 2 ; while ( even <= n ) { arr [ i ++ ] = even ; even += 2 ; } return arr [ k - 1 ] ; } public static void main ( String [ ] args ) { int n = 8 , k = 5 ; System . out . println ( getNumber ( n , k ) ) ; } }

Index/key variables: n
Accumulator variables: even, i, odd
Class/struct names: GFG
Java program:
class GFG { static void printArr ( int arr [ ] , int n ) { for ( int i = 0 ; i < n ; i ++ ) System . out . print ( arr [ i ] + " ▁ " ) ; } static void UpdateArr ( int arr [ ] , int n ) { int i = 0 , j = n - 1 ; while ( i < j ) { int temp = arr [ i ] ; arr [ i ] = arr [ j ] ; arr [ j ] = temp ; i += 2 ; j -= 2 ; } printArr ( arr , n ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 3 , 4 , 5 , 6 } ; int n = arr . length ; UpdateArr ( arr , n ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . Arrays ; import java . io . * ; class GFG { static int N = 20 ; static int [ ] fact = new int [ N ] ; static void pre ( ) { fact [ 0 ] = 1 ; for ( int i = 1 ; i < N ; i ++ ) { fact [ i ] = i * fact [ i - 1 ] ; } } static int CountPermutation ( int a [ ] , int n ) { int ways = 1 ; Arrays . sort ( a ) ; int size = 1 ; for ( int i = 1 ; i < n ; i ++ ) { if ( a [ i ] == a [ i - 1 ] ) { size ++ ; } else { ways *= fact [ size ] ; size = 1 ; } } ways *= fact [ size ] ; return ways ; } public static void main ( String [ ] args ) { int a [ ] = { 1 , 2 , 4 , 4 , 2 , 4 } ; int n = a . length ; pre ( ) ; System . out . println ( CountPermutation ( a , n ) ) ; } }

Index/key variables: N, i, size
Accumulator variables: i, size, ways
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int Next_greater ( int a [ ] , int n , int x ) { Arrays . sort ( a ) ; int low = 0 , high = n - 1 , ans = x + 1 ; while ( low <= high ) { int mid = ( low + high ) / 2 ; if ( a [ mid ] <= ans ) { if ( a [ mid ] == ans ) { ans ++ ; high = n - 1 ; } low = mid + 1 ; } else high = mid - 1 ; } return ans ; } public static void main ( String [ ] args ) { int a [ ] = { 1 , 5 , 10 , 4 , 7 } , x = 4 ; int n = a . length ; System . out . println ( Next_greater ( a , n , x ) ) ; } }

Index/key variables: mid
Accumulator variables: ans
Class/struct names: GFG