dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
import java . util . * ; class GFG { static void printPairs ( int arr [ ] , int n ) { boolean pair_exists = false ; Arrays . sort ( arr ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] < 0 ) { if ( java . util . Arrays . binarySearch ( arr , - arr [ i ] ) != - 1 ) { System . out . println ( arr [ i ] + " , ▁ " + - arr [ i ] ) ; pair_exists = true ; } } else break ; } if ( pair_exists == false ) System . out . println ( " No ▁ such ▁ pair ▁ exists " ) ; } public static void main ( String args [ ] ) { int arr [ ] = { 4 , 8 , 9 , - 4 , 1 , - 1 , - 8 , - 9 } ; int n = arr . length ; printPairs ( arr , n ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Boolean variables: pair_exists
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static boolean areSame ( Vector < Integer > a , Vector < Integer > b ) { Collections . sort ( a ) ; Collections . sort ( b ) ; return ( a == b ) ; } public static void main ( String [ ] args ) { Vector < Integer > a = new Vector < Integer > ( Arrays . asList ( 7 , 7 , 5 ) ) ; Vector < Integer > b = new Vector < Integer > ( Arrays . asList ( 7 , 5 , 5 ) ) ; if ( areSame ( a , b ) ) System . out . print ( "YesNEW_LINE"); else System . out . print ( "NoNEW_LINE"); } }

Class/struct names: GFG
Java program:
import java . util . LinkedList ; import java . util . Queue ; import java . util . Vector ; class Test { static int minEdgeBFS ( Vector < Integer > edges [ ] , int u , int v , int n ) { Vector < Boolean > visited = new Vector < Boolean > ( n ) ; for ( int i = 0 ; i < n ; i ++ ) { visited . addElement ( false ) ; } Vector < Integer > distance = new Vector < Integer > ( n ) ; for ( int i = 0 ; i < n ; i ++ ) { distance . addElement ( 0 ) ; } Queue < Integer > Q = new LinkedList < > ( ) ; distance . setElementAt ( 0 , u ) ; Q . add ( u ) ; visited . setElementAt ( true , u ) ; while ( ! Q . isEmpty ( ) ) { int x = Q . peek ( ) ; Q . poll ( ) ; for ( int i = 0 ; i < edges [ x ] . size ( ) ; i ++ ) { if ( visited . elementAt ( edges [ x ] . get ( i ) ) ) continue ; distance . setElementAt ( distance . get ( x ) + 1 , edges [ x ] . get ( i ) ) ; Q . add ( edges [ x ] . get ( i ) ) ; visited . setElementAt ( true , edges [ x ] . get ( i ) ) ; } } return distance . get ( v ) ; } static void addEdge ( Vector < Integer > edges [ ] , int u , int v ) { edges [ u ] . add ( v ) ; edges [ v ] . add ( u ) ; } public static void main ( String args [ ] ) { int n = 9 ; Vector < Integer > edges [ ] = new Vector [ 9 ] ; for ( int i = 0 ; i < edges . length ; i ++ ) { edges [ i ] = new Vector < > ( ) ; } addEdge ( edges , 0 , 1 ) ; addEdge ( edges , 0 , 7 ) ; addEdge ( edges , 1 , 7 ) ; addEdge ( edges , 1 , 2 ) ; addEdge ( edges , 2 , 3 ) ; addEdge ( edges , 2 , 5 ) ; addEdge ( edges , 2 , 8 ) ; addEdge ( edges , 3 , 4 ) ; addEdge ( edges , 3 , 5 ) ; addEdge ( edges , 4 , 5 ) ; addEdge ( edges , 5 , 6 ) ; addEdge ( edges , 6 , 7 ) ; addEdge ( edges , 7 , 8 ) ; int u = 0 ; int v = 5 ; System . out . println ( minEdgeBFS ( edges , u , v , n ) ) ; } }

Index/key variables: i, u, v, x
Accumulator variables: i
Iterator variables: i
Class/struct names: Test
Java program:
public class GFG { static int findMinimumSwaps ( int [ ] arr , int n , int k ) { int pos = 0 , num_min , num_max , need_minimum , need_maximum , swaps ; num_min = num_max = need_minimum = 0 ; need_maximum = swaps = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] < k ) { num_min ++ ; } else if ( arr [ i ] > k ) { num_max ++ ; } } for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] == k ) { pos = i ; break ; } } int left , right , mid ; left = 0 ; right = n - 1 ; while ( left <= right ) { mid = ( left + right ) / 2 ; if ( arr [ mid ] == k ) { break ; } else if ( arr [ mid ] > k ) { if ( pos > mid ) { need_minimum ++ ; } else { num_min -- ; } left = mid + 1 ; } else { if ( pos < mid ) { need_maximum ++ ; } else { num_max -- ; } right = mid - 1 ; } } if ( need_minimum > need_maximum ) { swaps = swaps + need_maximum ; num_min = num_min - need_maximum ; need_minimum = need_minimum - need_maximum ; need_maximum = 0 ; } else { swaps = swaps + need_minimum ; num_max = num_max - need_minimum ; need_maximum = need_maximum - need_minimum ; need_minimum = 0 ; } if ( need_maximum > num_max need_minimum > num_min ) { return - 1 ; } else { return ( swaps + need_maximum + need_minimum ) ; } } public static void main ( String [ ] args ) { int arr [ ] = { 3 , 10 , 6 , 7 , 2 , 5 , 4 } , k = 4 ; int n = arr . length ; System . out . println ( findMinimumSwaps ( arr , n , k ) ) ; } }

Index/key variables: i, mid
Accumulator variables: i, need_maximum, need_minimum, num_max, num_min
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void reverse ( int a [ ] ) { int i , k , n = a . length ; int t ; for ( i = 0 ; i < n / 2 ; i ++ ) { t = a [ i ] ; a [ i ] = a [ n - i - 1 ] ; a [ n - i - 1 ] = t ; } } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 5 , 8 , 9 , 6 , 7 , 3 , 4 , 2 , 0 } ; int n = arr . length ; Arrays . sort ( arr ) ; reverse ( arr ) ; System . out . println ( "Array after sorting : NEW_LINE"); for ( int i = 0 ; i < n ; ++ i ) { System . out . print ( arr [ i ] + " ▁ " ) ; } } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { static Boolean function ( char str [ ] ) { int l = str . length ; Arrays . sort ( str , 0 , ( l / 2 ) ) ; Arrays . sort ( str , ( l / 2 ) , l ) ; for ( int i = 0 ; i < l / 2 ; i ++ ) if ( str [ i ] != str [ l / 2 + i ] ) return true ; return false ; } public static void main ( String [ ] args ) { char str [ ] = ( " abcasdsabcae " ) . toCharArray ( ) ; if ( function ( str ) ) System . out . println ( " Yes , ▁ both ▁ halves ▁ differ " + " ▁ by ▁ at ▁ least ▁ one ▁ character " ) ; else System . out . println ( " No , ▁ both ▁ halves ▁ do " + " ▁ not ▁ differ ▁ at ▁ all " ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . ArrayList ; import java . util . List ; class GFG { static int [ ] inputArray = { 0 , 1 , 1 , 0 , 1 , 2 , 1 , 2 , 0 , 0 , 0 , 1 } ; static List < Integer > outputArray = new ArrayList < > ( ) ; static int indexOfOne = 0 ; static void print ( ) { for ( int item : inputArray ) if ( item == 2 ) outputArray . add ( item ) ; else if ( item == 1 ) { outputArray . add ( indexOfOne , item ) ; indexOfOne += 1 ; } else if ( item == 0 ) { outputArray . add ( 0 , item ) ; indexOfOne += 1 ; } else { System . out . println ( " ▁ wrong ▁ value ▁ - ▁ Aborting ▁ " ) ; continue ; } } public static void main ( String [ ] args ) { print ( ) ; for ( int item : outputArray ) System . out . print ( item + " , ▁ " ) ; } }

Accumulator variables: indexOfOne
Iterator variables: item
Class/struct names: GFG
Java program:
import java . util . LinkedList ; import java . util . Queue ; import java . util . Arrays ; public class GFG { static int minimumBox ( int [ ] arr , int n ) { Queue < Integer > q = new LinkedList < > ( ) ; Arrays . sort ( arr ) ; q . add ( arr [ 0 ] ) ; for ( int i = 1 ; i < n ; i ++ ) { int now = q . element ( ) ; if ( arr [ i ] >= 2 * now ) q . remove ( ) ; q . add ( arr [ i ] ) ; } return q . size ( ) ; } public static void main ( String args [ ] ) { int [ ] arr = { 4 , 1 , 2 , 8 } ; int n = arr . length ; System . out . println ( minimumBox ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void sortBinaryArray ( int a [ ] , int n ) { int j = - 1 ; for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] < 1 ) { j ++ ; int temp = a [ j ] ; a [ j ] = a [ i ] ; a [ i ] = temp ; } } } public static void main ( String [ ] args ) { int a [ ] = { 1 , 0 , 0 , 1 , 0 , 1 , 0 , 1 , 1 , 1 , 1 , 1 , 1 , 0 , 0 , 1 , 1 , 0 , 1 , 0 , 0 } ; int n = a . length ; sortBinaryArray ( a , n ) ; for ( int i = 0 ; i < n ; i ++ ) System . out . print ( a [ i ] + " ▁ " ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i
Class/struct names: GFG
Java program:
public class GFG { static final int MAX = 1000 ; static int findDuplicate ( int arr [ ] , int n , int k ) { int res = MAX + 1 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] > 0 ) { int count = 1 ; for ( int j = i + 1 ; j < n ; j ++ ) if ( arr [ i ] == arr [ j ] ) count += 1 ; if ( count == k ) res = Math . min ( res , arr [ i ] ) ; } } return res ; } public static void main ( String [ ] args ) { int arr [ ] = { 2 , 2 , 1 , 3 , 1 } ; int k = 2 ; int n = arr . length ; System . out . println ( findDuplicate ( arr , 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 . Arrays ; public class GFG { static int findDuplicate ( int arr [ ] , int n , int k ) { Arrays . sort ( arr ) ; int i = 0 ; while ( i < n ) { int j , count = 1 ; for ( j = i + 1 ; j < n && arr [ j ] == arr [ i ] ; j ++ ) count ++ ; if ( count == k ) return arr [ i ] ; i = j ; } return - 1 ; } public static void main ( String [ ] args ) { int arr [ ] = { 2 , 2 , 1 , 3 , 1 } ; int k = 2 ; int n = arr . length ; System . out . println ( findDuplicate ( arr , n , k ) ) ; } }

Index/key variables: i, j
Accumulator variables: count, j
Iterator variables: j
Class/struct names: GFG
Java program:
import java . util . * ; public class GFG { public String longestCommonPrefix ( String [ ] a ) { int size = a . length ; if ( size == 0 ) return " " ; if ( size == 1 ) return a [ 0 ] ; Arrays . sort ( a ) ; int end = Math . min ( a [ 0 ] . length ( ) , a [ size - 1 ] . length ( ) ) ; int i = 0 ; while ( i < end && a [ 0 ] . charAt ( i ) == a [ size - 1 ] . charAt ( i ) ) i ++ ; String pre = a [ 0 ] . substring ( 0 , i ) ; return pre ; } public static void main ( String [ ] args ) { GFG gfg = new GFG ( ) ; String [ ] input = { " geeksforgeeks " , " geeks " , " geek " , " geezer " } ; System . out . println ( " The ▁ longest ▁ Common ▁ Prefix ▁ is ▁ : ▁ " + gfg . longestCommonPrefix ( input ) ) ; } }

Accumulator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . Arrays ; import java . lang . Math ; class GFG { static void find ( int [ ] arr , int n , int k ) { Arrays . sort ( arr ) ; int b = ( int ) Math . ceil ( n / k * 1.0 ) ; int min_sum = 0 , max_sum = 0 ; for ( int i = 0 ; i < b ; i ++ ) min_sum += arr [ i ] ; for ( int i = 2 ; i < arr . length ; i ++ ) max_sum += arr [ i ] ; System . out . println ( " minimum ▁ " + min_sum ) ; System . out . println ( " maximum ▁ " + max_sum ) ; } public static void main ( String [ ] args ) { int [ ] arr = { 3 , 2 , 1 , 4 } ; int n = arr . length ; int k = 2 ; find ( arr , n , k ) ; } }

Index/key variables: i
Accumulator variables: i, max_sum, min_sum
Iterator variables: i
Class/struct names: GFG
Java program:
class Main { static boolean checkForSorting ( int arr [ ] , int n ) { for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( arr [ i ] > arr [ i + 1 ] ) { if ( arr [ i ] - arr [ i + 1 ] == 1 ) { int temp = arr [ i ] ; arr [ i ] = arr [ i + 1 ] ; arr [ i + 1 ] = temp ; } else return false ; } } return true ; } public static void main ( String args [ ] ) { int arr [ ] = { 1 , 0 , 3 , 2 } ; int n = arr . length ; if ( checkForSorting ( arr , n ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: Main
Java program:
import java . util . * ; class solution { static void sort ( String [ ] s , int n ) { for ( int i = 1 ; i < n ; i ++ ) { String temp = s [ i ] ; int j = i - 1 ; while ( j >= 0 && temp . length ( ) < s [ j ] . length ( ) ) { s [ j + 1 ] = s [ j ] ; j -- ; } s [ j + 1 ] = temp ; } } static void printArraystring ( String str [ ] , int n ) { for ( int i = 0 ; i < n ; i ++ ) System . out . print ( str [ i ] + " ▁ " ) ; } public static void main ( String args [ ] ) { String [ ] arr = { " GeeksforGeeks " , " I " , " from " , " am " } ; int n = arr . length ; sort ( arr , n ) ; printArraystring ( arr , n ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i
Class/struct names: solution
Java program:
import java . io . * ; class GFG { static int partition ( int [ ] arr , int low , int high ) { int pivot = arr [ low ] ; int i = low - 1 , j = high + 1 ; while ( true ) { do { i ++ ; } while ( arr [ i ] < pivot ) ; do { j -- ; } while ( arr [ j ] > pivot ) ; if ( i >= j ) return j ; int temp = arr [ i ] ; arr [ i ] = arr [ j ] ; arr [ j ] = temp ; } } static void quickSort ( int [ ] arr , int low , int high ) { if ( low < high ) { int pi = partition ( arr , low , high ) ; quickSort ( arr , low , pi ) ; quickSort ( arr , pi + 1 , high ) ; } } static void printArray ( int [ ] arr , int n ) { for ( int i = 0 ; i < n ; i ++ ) System . out . print ( " ▁ " + arr [ i ] ) ; System . out . println ( ) ; } static public void main ( String [ ] args ) { int [ ] arr = { 10 , 7 , 8 , 9 , 1 , 5 } ; int n = arr . length ; quickSort ( arr , 0 , n - 1 ) ; System . out . println ( " Sorted ▁ array : ▁ " ) ; printArray ( arr , n ) ; } }

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

Index/key variables: i
Accumulator variables: i, k
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { class Node { int key ; Node left , right ; public Node ( int item ) { key = item ; left = right = null ; } } Node root ; GFG ( ) { root = null ; } void insert ( int key ) { root = insertRec ( root , key ) ; } Node insertRec ( Node root , int key ) { if ( root == null ) { root = new Node ( key ) ; return root ; } if ( key < root . key ) root . left = insertRec ( root . left , key ) ; else if ( key > root . key ) root . right = insertRec ( root . right , key ) ; return root ; } void inorderRec ( Node root ) { if ( root != null ) { inorderRec ( root . left ) ; System . out . print ( root . key + " ▁ " ) ; inorderRec ( root . right ) ; } } void treeins ( int arr [ ] ) { for ( int i = 0 ; i < arr . length ; i ++ ) { insert ( arr [ i ] ) ; } } public static void main ( String [ ] args ) { GFG tree = new GFG ( ) ; int arr [ ] = { 5 , 4 , 7 , 2 , 11 } ; tree . treeins ( arr ) ; tree . inorderRec ( tree . root ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG, Node
Java program:
class GFG { public static boolean isEven ( int n ) { if ( ( n & 1 ) == 0 ) return true ; else return false ; } return true ; else return false ; } public static void main ( String [ ] args ) { int n = 101 ; if ( isEven ( n ) == true ) System . out . print ( " Even " ) ; else System . out . print ( " Odd " ) ; } }

Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int findSubsequenceCount ( String S , String T ) { int m = T . length ( ) ; int n = S . length ( ) ; if ( m > n ) return 0 ; int mat [ ] [ ] = new int [ m + 1 ] [ n + 1 ] ; for ( int i = 1 ; i <= m ; i ++ ) mat [ i ] [ 0 ] = 0 ; for ( int j = 0 ; j <= n ; j ++ ) mat [ 0 ] [ j ] = 1 ; for ( int i = 1 ; i <= m ; i ++ ) { for ( int j = 1 ; j <= n ; j ++ ) { if ( T . charAt ( i - 1 ) != S . charAt ( j - 1 ) ) mat [ i ] [ j ] = mat [ i ] [ j - 1 ] ; else mat [ i ] [ j ] = mat [ i ] [ j - 1 ] + mat [ i - 1 ] [ j - 1 ] ; } } return mat [ m ] [ n ] ; } public static void main ( String [ ] args ) { String T = " ge " ; String S = " geeksforgeeks " ; System . out . println ( findSubsequenceCount ( S , T ) ) ; } }

Index/key variables: i, j, m, n
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int i , j ; static void partition ( int a [ ] , int l , int r ) { i = l - 1 ; j = r ; int p = l - 1 , q = r ; int v = a [ r ] ; while ( true ) { while ( a [ ++ i ] < v ) ; while ( v < a [ -- j ] ) if ( j == l ) break ; if ( i >= j ) break ; int temp = a [ i ] ; a [ i ] = a [ j ] ; a [ j ] = temp ; if ( a [ i ] == v ) { p ++ ; temp = a [ i ] ; a [ i ] = a [ p ] ; a [ p ] = temp ; } if ( a [ j ] == v ) { q -- ; temp = a [ q ] ; a [ q ] = a [ j ] ; a [ j ] = temp ; } } int temp = a [ i ] ; a [ i ] = a [ r ] ; a [ r ] = temp ; j = i - 1 ; for ( int k = l ; k < p ; k ++ , j -- ) { temp = a [ k ] ; a [ k ] = a [ j ] ; a [ j ] = temp ; } i = i + 1 ; for ( int k = r - 1 ; k > q ; k -- , i ++ ) { temp = a [ i ] ; a [ i ] = a [ k ] ; a [ k ] = temp ; } } static void quicksort ( int a [ ] , int l , int r ) { if ( r <= l ) return ; i = 0 ; j = 0 ; partition ( a , l , r ) ; quicksort ( a , l , j ) ; quicksort ( a , i , r ) ; } static void printarr ( int a [ ] , int n ) { for ( int i = 0 ; i < n ; ++ i ) System . out . printf ( " % d ▁ " , a [ i ] ) ; System . out . printf ( "NEW_LINE"); } public static void main ( String [ ] args ) { int a [ ] = { 4 , 9 , 4 , 4 , 1 , 9 , 4 , 4 , 9 , 4 , 4 , 1 , 4 } ; int size = a . length ; printarr ( a , size ) ; quicksort ( a , 0 , size - 1 ) ; printarr ( a , size ) ; } }

Index/key variables: i, j, k, p, q, r
Accumulator variables: i, j, k, p, q
Iterator variables: i, k
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static class pair { int first , second ; public pair ( int first , int second ) { this . first = first ; this . second = second ; } } static int checkRBS ( String [ ] S ) { int N = S . length ; pair [ ] v = new pair [ N ] ; for ( int i = 0 ; i < N ; ++ i ) { String s = S [ i ] ; int sum = 0 ; int pre = 0 ; for ( char c : s . toCharArray ( ) ) { if ( c == ' ( ' ) { ++ sum ; } else { -- sum ; } pre = Math . min ( sum , pre ) ; } v [ i ] = new pair ( sum , pre ) ; } Vector < pair > pos = new Vector < pair > ( ) ; Vector < pair > neg = new Vector < pair > ( ) ; for ( int i = 0 ; i < N ; ++ i ) { if ( v [ i ] . first >= 0 ) { pos . add ( new pair ( - v [ i ] . second , v [ i ] . first ) ) ; } else { neg . add ( new pair ( v [ i ] . first - v [ i ] . second , - v [ i ] . first ) ) ; } } Collections . sort ( pos , ( a , b ) -> a . first - b . first ) ; int open = 0 ; for ( pair p : pos ) { if ( open - p . first >= 0 ) { open += p . second ; } else { System . out . print ( " No " + "NEW_LINE"); return 0 ; } } Collections . sort ( neg , ( a , b ) -> a . first - b . first ) ; int negative = 0 ; for ( pair p : neg ) { if ( negative - p . first >= 0 ) { negative += p . second ; } else { System . out . print ( "NoNEW_LINE"); return 0 ; } } if ( open != negative ) { System . out . print ( "NoNEW_LINE"); return 0 ; } System . out . print ( "YesNEW_LINE"); return 0 ; } public static void main ( String [ ] args ) { String [ ] arr = { " ) " , " ( ) ( " } ; checkRBS ( arr ) ; } }

Index/key variables: N, i
Accumulator variables: negative, open
Iterator variables: c, i, p
Class/struct names: GFG, pair
Java program:
import java . io . * ; class GFG { static int maximumUniqueSquares ( int N ) { int ans = 0 ; if ( N < 4 ) { return 0 ; } int len = ( int ) ( Math . sqrt ( N ) ) ; N -= len * len ; for ( int i = 1 ; i < len ; i ++ ) { ans += i * i ; } if ( N >= len ) { N -= len ; for ( int i = 1 ; i < len ; i ++ ) { ans += i ; } } for ( int i = 1 ; i < N ; i ++ ) { ans += i ; } return ans ; } public static void main ( String [ ] args ) { int N = 9 ; System . out . println ( maximumUniqueSquares ( N ) ) ; } }

Accumulator variables: N, ans, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void findPermutation ( int K , Vector < Integer > arr ) { Vector < Integer > missing = new Vector < Integer > ( ) ; boolean visited [ ] = new boolean [ K + 1 ] ; for ( int i = 0 ; i < arr . size ( ) ; i ++ ) { visited [ arr . get ( i ) ] = true ; } for ( int i = 1 ; i <= K ; i ++ ) { if ( ! visited [ i ] ) { missing . add ( i ) ; } } arr . add ( Integer . MAX_VALUE ) ; missing . add ( Integer . MAX_VALUE ) ; int p1 = 0 ; int p2 = 0 ; Vector < Integer > ans = new Vector < Integer > ( ) ; while ( ans . size ( ) < K ) { if ( arr . get ( p1 ) < missing . get ( p2 ) ) { ans . add ( arr . get ( p1 ) ) ; p1 ++ ; } else { ans . add ( missing . get ( p2 ) ) ; p2 ++ ; } } for ( int i = 0 ; i < K ; i ++ ) { System . out . print ( ans . get ( i ) + " ▁ " ) ; } } public static void main ( String [ ] args ) { int K = 7 ; Integer [ ] a = { 6 , 4 , 2 , 1 } ; Vector < Integer > arr = new Vector < > ( Arrays . asList ( a ) ) ; findPermutation ( K , arr ) ; } }

Index/key variables: i
Accumulator variables: i, p1, p2
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; import java . lang . * ; import java . lang . Math ; class GFG { static int findRemainingIndex ( int N ) { int ans = N ; while ( N > 1 ) { int discard = ( int ) ( Math . sqrt ( N ) ) ; if ( discard * discard == N ) { ans -- ; } N -= discard ; } return ans ; } static void findRemainingElement ( int arr [ ] , int N ) { int remainingIndex = findRemainingIndex ( N ) ; System . out . print ( arr [ remainingIndex - 1 ] ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 2 , 3 , 4 , 4 , 2 , 4 , - 3 , 1 , 1 } ; int N = 9 ; findRemainingElement ( arr , N ) ; } }

Accumulator variables: N, ans
Class/struct names: GFG
Java program:
public class Main { static String largestMerge ( String s1 , String s2 ) { if ( s1 . length ( ) == 0 || s2 . length ( ) == 0 ) return s1 + s2 ; if ( s1 . compareTo ( s2 ) > 0 ) { return s1 . charAt ( 0 ) + largestMerge ( s1 . substring ( 1 ) , s2 ) ; } return s2 . charAt ( 0 ) + largestMerge ( s1 , s2 . substring ( 1 ) ) ; } public static void main ( String [ ] args ) { String s1 = " geeks " ; String s2 = " forgeeks " ; System . out . print ( largestMerge ( s1 , s2 ) ) ; } }

Class/struct names: Main
Java program:
import java . io . * ; import java . util . * ; class GFG { static int shortestDistance ( String S , int N ) { HashMap < Character , Integer > dic = new HashMap < Character , Integer > ( ) ; ArrayList < Integer > dis = new ArrayList < > ( ) ; int var ; for ( int i = 0 ; i < N ; i ++ ) { if ( dic . get ( S . charAt ( i ) ) != null ) { var = i - dic . get ( S . charAt ( i ) ) ; dic . put ( S . charAt ( i ) , i ) ; dis . add ( var ) ; } else { dic . put ( S . charAt ( i ) , i ) ; } } if ( dis . size ( ) == 0 ) return - 1 ; else return Collections . min ( dis ) - 1 ; } public static void main ( String [ ] args ) { String S = " geeksforgeeks " ; int N = 13 ; System . out . println ( shortestDistance ( S , N ) ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int countOpenDoors ( int N ) { int doorsOpen = ( int ) Math . sqrt ( N ) ; return doorsOpen ; } public static void main ( String [ ] args ) { int N = 100 ; System . out . println ( countOpenDoors ( N ) ) ; } }

Class/struct names: GFG