dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
import java . util . * ; public class GFG { static int LongestFibSubseq ( int A [ ] , int n ) { TreeSet < Integer > S = new TreeSet < > ( ) ; for ( int t : A ) { S . add ( t ) ; } int maxLen = 0 , x , y ; for ( int i = 0 ; i < n ; ++ i ) { for ( int j = i + 1 ; j < n ; ++ j ) { x = A [ j ] ; y = A [ i ] + A [ j ] ; int length = 3 ; while ( S . contains ( y ) && ( y != S . last ( ) ) ) { int z = x + y ; x = y ; y = z ; maxLen = Math . max ( maxLen , ++ length ) ; } } } return maxLen >= 3 ? maxLen : 0 ; } public static void main ( String [ ] args ) { int A [ ] = { 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 } ; int n = A . length ; System . out . print ( LongestFibSubseq ( A , n ) ) ; } }

Index/key variables: i, j
Iterator variables: i, j, t
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { public static int num_candyTypes ( int [ ] candies ) { Dictionary < Integer , Integer > s = new Hashtable < Integer , Integer > ( ) ; for ( int i = 0 ; i < candies . length ; i ++ ) { s . put ( candies [ i ] , 1 ) ; } return s . size ( ) ; } public static void distribute_candies ( int [ ] candies ) { int allowed = candies . length / 2 ; int types = num_candyTypes ( candies ) ; if ( types < allowed ) System . out . println ( types ) ; else System . out . println ( allowed ) ; } public static void main ( String [ ] args ) { int candies [ ] = { 4 , 4 , 5 , 5 , 3 , 3 } ; distribute_candies ( candies ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static double [ ] Length_Diagonals ( int a , double theta ) { double p = a * Math . sqrt ( 2 + ( 2 * Math . cos ( theta * ( Math . PI / 180 ) ) ) ) ; double q = a * Math . sqrt ( 2 - ( 2 * Math . cos ( theta * ( Math . PI / 180 ) ) ) ) ; return new double [ ] { p , q } ; } public static void main ( String [ ] args ) { int A = 6 ; double theta = 45 ; double [ ] ans = Length_Diagonals ( A , theta ) ; System . out . printf ( " % .2f " + " ▁ " + " % .2f " , ans [ 0 ] , ans [ 1 ] ) ; } }

Class/struct names: GFG
Java program:
class GFG { static int __builtin_popcount ( int n ) { int count = 0 ; while ( n > 0 ) { count += n & 1 ; n >>= 1 ; } return count ; } static void countEvenOdd ( int arr [ ] , int n , int K ) { int even = 0 , odd = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int x = __builtin_popcount ( arr [ i ] ) ; if ( x % 2 == 0 ) even ++ ; else odd ++ ; } int y ; y = __builtin_popcount ( K ) ; if ( ( y & 1 ) != 0 ) { System . out . println ( " Even ▁ = ▁ " + odd + " , ▁ Odd ▁ = ▁ " + even ) ; } else { System . out . println ( " Even ▁ = ▁ " + even + " , ▁ Odd ▁ = ▁ " + odd ) ; } } public static void main ( String [ ] args ) { int arr [ ] = { 4 , 2 , 15 , 9 , 8 , 8 } ; int K = 3 ; int n = arr . length ; countEvenOdd ( arr , n , K ) ; } }

Index/key variables: i
Accumulator variables: count, even, i, odd
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; import java . lang . * ; import java . io . * ; class GFG { public static void main ( String args [ ] ) { int N = 6 ; int Even = N / 2 ; int Odd = N - Even ; System . out . println ( Even * Odd ) ; } }

Class/struct names: GFG
Java program:
class GFG { public static Integer longestSubSequence ( int [ ] [ ] A , int N , int ind , int lastf , int lasts ) { ind = ( ind > 0 ? ind : 0 ) ; lastf = ( lastf > 0 ? lastf : Integer . MIN_VALUE ) ; lasts = ( lasts > 0 ? lasts : Integer . MAX_VALUE ) ; if ( ind == N ) return 0 ; int ans = longestSubSequence ( A , N , ind + 1 , lastf , lasts ) ; if ( A [ ind ] [ 0 ] > lastf && A [ ind ] [ 1 ] < lasts ) ans = Math . max ( ans , longestSubSequence ( A , N , ind + 1 , A [ ind ] [ 0 ] , A [ ind ] [ 1 ] ) + 1 ) ; return ans ; } public static int longestSubSequence ( int [ ] [ ] A , int N ) { return longestSubSequence ( A , N , 0 , 0 , 0 ) ; } public static void main ( String args [ ] ) { int [ ] [ ] A = { { 1 , 2 } , { 2 , 2 } , { 3 , 1 } } ; int N = A . length ; System . out . println ( longestSubSequence ( A , N ) ) ; } }

Index/key variables: ind
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int countTriplets ( int [ ] A ) { int cnt = 0 ; HashMap < Integer , Integer > tuples = new HashMap < Integer , Integer > ( ) ; for ( int a : A ) for ( int b : A ) { if ( tuples . containsKey ( a & b ) ) tuples . put ( a & b , tuples . get ( a & b ) + 1 ) ; else tuples . put ( a & b , 1 ) ; } for ( int a : A ) for ( Map . Entry < Integer , Integer > t : tuples . entrySet ( ) ) if ( ( t . getKey ( ) & a ) == 0 ) cnt += t . getValue ( ) ; return cnt ; } public static void main ( String [ ] args ) { int [ ] A = { 2 , 1 , 3 } ; System . out . print ( countTriplets ( A ) ) ; } }

Accumulator variables: cnt
Iterator variables: a, b
Class/struct names: GFG
Java program:
import java . util . Arrays ; class GfG { static int CountWays ( int n ) { int noOfWays [ ] = new int [ n + 3 ] ; noOfWays [ 0 ] = 1 ; noOfWays [ 1 ] = 1 ; noOfWays [ 2 ] = 1 + 1 ; for ( int i = 3 ; i < n + 1 ; i ++ ) { noOfWays [ i ] = noOfWays [ i - 1 ] + noOfWays [ i - 3 ] ; } return noOfWays [ n ] ; } public static void main ( String [ ] args ) { int n = 5 ; System . out . println ( CountWays ( n ) ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GfG
Java program:
public class GFG { public static void printSpiral ( int size ) { int row = 0 , col = 0 ; int boundary = size - 1 ; int sizeLeft = size - 1 ; int flag = 1 ; char move = ' r ' ; int matrix [ ] [ ] = new int [ size ] [ size ] ; for ( int i = 1 ; i < size * size + 1 ; i ++ ) { matrix [ row ] [ col ] = i ; switch ( move ) { case ' r ' : col += 1 ; break ; case ' l ' : col -= 1 ; break ; case ' u ' : row -= 1 ; break ; case ' d ' : row += 1 ; break ; } if ( i == boundary ) { boundary += sizeLeft ; if ( flag != 2 ) { flag = 2 ; } else { flag = 1 ; sizeLeft -= 1 ; } switch ( move ) { case ' r ' : move = ' d ' ; break ; case ' d ' : move = ' l ' ; break ; case ' l ' : move = ' u ' ; break ; case ' u ' : move = ' r ' ; break ; } } } for ( row = 0 ; row < size ; row ++ ) { for ( col = 0 ; col < size ; col ++ ) { int n = matrix [ row ] [ col ] ; System . out . print ( ( n < 10 ) ? ( n + " ▁ " ) : ( n + " ▁ " ) ) ; } System . out . println ( ) ; } } public static void main ( String [ ] args ) { int size = 5 ; printSpiral ( size ) ; } }

Index/key variables: col, row, size
Accumulator variables: boundary, col, i, row, sizeLeft
Iterator variables: col, i, row
Class/struct names: GFG
Java program:
import java . util . * ; public class GFG { static void findWinner ( String a , int n ) { Vector < Integer > v = new Vector < Integer > ( ) ; int c = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( a . charAt ( i ) == '0' ) { c ++ ; } else { if ( c != 0 ) v . add ( c ) ; c = 0 ; } } if ( c != 0 ) v . add ( c ) ; if ( v . size ( ) == 0 ) { System . out . print ( " Player ▁ B " ) ; return ; } if ( v . size ( ) == 1 ) { if ( ( v . get ( 0 ) & 1 ) != 0 ) System . out . print ( " Player ▁ A " ) ; else System . out . print ( " Player ▁ B " ) ; return ; } int first = Integer . MIN_VALUE ; int second = Integer . MIN_VALUE ; for ( int i = 0 ; i < v . size ( ) ; i ++ ) { if ( a . charAt ( i ) > first ) { second = first ; first = a . charAt ( i ) ; } else if ( a . charAt ( i ) > second && a . charAt ( i ) != first ) second = a . charAt ( i ) ; } if ( ( first & 1 ) != 0 && ( first + 1 ) / 2 > second ) System . out . print ( " Player ▁ A " ) ; else System . out . print ( " Player ▁ B " ) ; } public static void main ( String [ ] args ) { String S = "1100011" ; int N = S . length ( ) ; findWinner ( S , N ) ; } }

Accumulator variables: c, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static boolean can_Construct ( String S , int K ) { Map < Character , Integer > m = new HashMap < > ( ) ; int p = 0 ; if ( S . length ( ) == K ) return true ; for ( int i = 0 ; i < S . length ( ) ; i ++ ) m . put ( S . charAt ( i ) , m . getOrDefault ( S . charAt ( i ) , 0 ) + 1 ) ; if ( K > S . length ( ) ) return false ; else { for ( Integer h : m . values ( ) ) { if ( h % 2 != 0 ) p = p + 1 ; } } if ( K < p ) return false ; return true ; } public static void main ( String [ ] args ) { String S = " annabelle " ; int K = 4 ; if ( can_Construct ( S , K ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } }

Accumulator variables: i
Iterator variables: h, i
Class/struct names: GFG
Java program:
class GFG { static boolean equalIgnoreCase ( String str1 , String str2 ) { int i = 0 ; str1 = str1 . toLowerCase ( ) ; str2 = str2 . toLowerCase ( ) ; int x = str1 . compareTo ( str2 ) ; return x == 0 ; } static void equalIgnoreCaseUtil ( String str1 , String str2 ) { boolean res = equalIgnoreCase ( str1 , str2 ) ; if ( res == true ) System . out . println ( " Same " ) ; else System . out . println ( " Not ▁ Same " ) ; } public static void main ( String [ ] args ) { String str1 , str2 ; str1 = " Geeks " ; str2 = " geeks " ; equalIgnoreCaseUtil ( str1 , str2 ) ; str1 = " Geek " ; str2 = " geeksforgeeks " ; equalIgnoreCaseUtil ( str1 , str2 ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; class solution { static void steps ( String str , int n ) { boolean flag = false ; int x = 0 ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { if ( x == 0 ) flag = true ; if ( x == n - 1 ) flag = false ; for ( int j = 0 ; j < x ; j ++ ) System . out . print ( " * " ) ; System . out . print ( str . charAt ( i ) + "NEW_LINE"); if ( flag == true ) x ++ ; else x -- ; } } public static void main ( String args [ ] ) { int n = 4 ; String str = " GeeksForGeeks " ; System . out . println ( " String : ▁ " + str ) ; System . out . println ( " Max ▁ Length ▁ of ▁ Steps : ▁ " + n ) ; steps ( str , n ) ; } }

Accumulator variables: i, j, x
Iterator variables: i, j
Boolean variables: flag
Class/struct names: solution
Java program:
import java . util . * ; class GFG { static void countFreq ( int arr [ ] , int n ) { boolean [ ] visited = new boolean [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { if ( visited [ i ] == true ) continue ; int count = 1 ; for ( int j = i + 1 ; j < n ; j ++ ) { if ( arr [ i ] == arr [ j ] ) { visited [ j ] = true ; count ++ ; } } System . out . println ( arr [ i ] + " ▁ " + count ) ; } } public static void main ( String [ ] args ) { int arr [ ] = { 10 , 20 , 20 , 10 , 10 , 20 , 5 , 20 } ; int n = arr . length ; countFreq ( arr , n ) ; } }

Index/key variables: i, j, n
Accumulator variables: count, i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
class GFG { static boolean isDivisible ( String str , int k ) { int n = str . length ( ) ; int c = 0 ; for ( int i = 0 ; i < k ; i ++ ) if ( str . charAt ( n - i - 1 ) == '0' ) c ++ ; return ( c == k ) ; } public static void main ( String args [ ] ) { String str1 = "10101100" ; int k = 2 ; if ( isDivisible ( str1 , k ) == true ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; String str2 = "111010100" ; k = 2 ; if ( isDivisible ( str2 , k ) == true ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } }

Accumulator variables: c, i
Iterator variables: i
Class/struct names: GFG
Java program:
public class GFG { static final int NO_OF_CHARS = 256 ; static boolean canFormPalindrome ( String str ) { int [ ] count = new int [ NO_OF_CHARS ] ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) count [ str . charAt ( i ) ] ++ ; int odd = 0 ; for ( int i = 0 ; i < NO_OF_CHARS ; i ++ ) { if ( ( count [ i ] & 1 ) != 0 ) odd ++ ; if ( odd > 1 ) return false ; } return true ; } public static void main ( String args [ ] ) { System . out . println ( canFormPalindrome ( " geeksforgeeks " ) ? " Yes " : " No " ) ; System . out . println ( canFormPalindrome ( " geeksogeeks " ) ? " Yes " : " No " ) ; } }

Index/key variables: NO_OF_CHARS, i
Accumulator variables: i, odd
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; public class GFG { static boolean isNumber ( String s ) { for ( int i = 0 ; i < s . length ( ) ; i ++ ) if ( Character . isDigit ( s . charAt ( i ) ) == false ) return false ; return true ; } static public void main ( String [ ] args ) { String str = "6790" ; if ( isNumber ( str ) ) System . out . println ( " Integer " ) ; else System . out . println ( " String " ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class StringReverse { void reverse ( String str ) { if ( ( str == null ) || ( str . length ( ) <= 1 ) ) System . out . println ( str ) ; else { System . out . print ( str . charAt ( str . length ( ) - 1 ) ) ; reverse ( str . substring ( 0 , str . length ( ) - 1 ) ) ; } } public static void main ( String [ ] args ) { String str = " Geeks ▁ for ▁ Geeks " ; StringReverse obj = new StringReverse ( ) ; obj . reverse ( str ) ; } }

Class/struct names: StringReverse
Java program:
import java . io . * ; import java . util . * ; class GFG { static int box1 = 0 ; static int box2 = 0 ; static int [ ] fact = new int [ 11 ] ; public static double getProbability ( int [ ] balls ) { factorial ( 10 ) ; box2 = balls . length ; int K = 0 ; for ( int i = 0 ; i < balls . length ; i ++ ) K += balls [ i ] ; if ( K % 2 == 1 ) return 0 ; long all = comb ( K , K / 2 ) ; long validPermutations = validPermutations ( K / 2 , balls , 0 , 0 ) ; return ( double ) validPermutations / all ; } static long validPermutations ( int n , int [ ] balls , int usedBalls , int i ) { if ( usedBalls == n ) { return box1 == box2 ? 1 : 0 ; } if ( i >= balls . length ) return 0 ; long res = validPermutations ( n , balls , usedBalls , i + 1 ) ; box1 ++ ; for ( int j = 1 ; j <= balls [ i ] ; j ++ ) { if ( j == balls [ i ] ) box2 -- ; long combinations = comb ( balls [ i ] , j ) ; res += combinations * validPermutations ( n , balls , usedBalls + j , i + 1 ) ; } box1 -- ; box2 ++ ; return res ; } static void factorial ( int N ) { fact [ 0 ] = 1 ; for ( int i = 1 ; i <= N ; i ++ ) fact [ i ] = fact [ i - 1 ] * i ; } static long comb ( int n , int r ) { long res = fact [ n ] / fact [ r ] ; res /= fact [ n - r ] ; return res ; } public static void main ( String [ ] args ) { int [ ] arr = { 2 , 1 , 1 } ; int N = 4 ; System . out . println ( getProbability ( arr ) ) ; } }

Index/key variables: i, n, r
Accumulator variables: K, box1, box2, i, j, res
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static double polyarea ( double n , double r ) { if ( r < 0 && n < 0 ) return - 1 ; double A = ( ( r * r * n ) * Math . sin ( ( 360 / n ) * 3.14159 / 180 ) ) / 2 ; return A ; } public static void main ( String [ ] args ) { float r = 9 , n = 6 ; System . out . println ( polyarea ( n , r ) ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void is_partition_possible ( int n , int x [ ] , int y [ ] , int w [ ] ) { Map < Integer , Integer > weight_at_x = new HashMap < Integer , Integer > ( ) ; int max_x = ( int ) - 2e3 , min_x = ( int ) 2e3 ; for ( int i = 0 ; i < n ; i ++ ) { int new_x = x [ i ] - y [ i ] ; max_x = Math . max ( max_x , new_x ) ; min_x = Math . min ( min_x , new_x ) ; if ( weight_at_x . containsKey ( new_x ) ) { weight_at_x . put ( new_x , weight_at_x . get ( new_x ) + w [ i ] ) ; } else { weight_at_x . put ( new_x , w [ i ] ) ; } } Vector < Integer > sum_till = new Vector < > ( ) ; sum_till . add ( 0 ) ; for ( int s = min_x ; s <= max_x ; s ++ ) { if ( weight_at_x . get ( s ) == null ) sum_till . add ( sum_till . lastElement ( ) ) ; else sum_till . add ( sum_till . lastElement ( ) + weight_at_x . get ( s ) ) ; } int total_sum = sum_till . lastElement ( ) ; int partition_possible = 0 ; for ( int i = 1 ; i < sum_till . size ( ) ; i ++ ) { if ( sum_till . get ( i ) == total_sum - sum_till . get ( i ) ) partition_possible = 1 ; if ( sum_till . get ( i - 1 ) == total_sum - sum_till . get ( i ) ) partition_possible = 1 ; } System . out . printf ( partition_possible == 1 ? "YES " ▁ : ▁ " NO "); } public static void main ( String [ ] args ) { int n = 3 ; int x [ ] = { - 1 , - 2 , 1 } ; int y [ ] = { 1 , 1 , - 1 } ; int w [ ] = { 3 , 1 , 4 } ; is_partition_possible ( n , x , y , w ) ; } }

Index/key variables: i
Accumulator variables: i, s
Iterator variables: i, s
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { static double findPCSlope ( double m ) { return - 1.0 / m ; } public static void main ( String [ ] args ) { double m = 2.0 ; System . out . println ( findPCSlope ( m ) ) ; } }

Class/struct names: GFG
Java program:
class GFG { static float pi = 3.14159f ; static float area_of_segment ( float radius , float angle ) { float area_of_sector = pi * ( radius * radius ) * ( angle / 360 ) ; float area_of_triangle = ( float ) 1 / 2 * ( radius * radius ) * ( float ) Math . sin ( ( angle * pi ) / 180 ) ; return area_of_sector - area_of_triangle ; } public static void main ( String [ ] args ) { float radius = 10.0f , angle = 90.0f ; System . out . println ( " Area ▁ of ▁ minor ▁ segment ▁ = ▁ " + area_of_segment ( radius , angle ) ) ; System . out . println ( " Area ▁ of ▁ major ▁ segment ▁ = ▁ " + area_of_segment ( radius , ( 360 - angle ) ) ) ; } }

Class/struct names: GFG
Java program:
class GFG { static void SectorArea ( double radius , double angle ) { if ( angle >= 360 ) System . out . println ( " Angle ▁ not ▁ possible " ) ; else { double sector = ( ( 22 * radius * radius ) / 7 ) * ( angle / 360 ) ; System . out . println ( sector ) ; } } public static void main ( String [ ] args ) { double radius = 9 ; double angle = 60 ; SectorArea ( radius , angle ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; public class Main { static int gcd ( int a , int b ) { if ( b == 0 ) { return a ; } return gcd ( b , a % b ) ; } static HashMap < Integer , Integer > PrimeFactor ( int N ) { HashMap < Integer , Integer > primef = new HashMap < Integer , Integer > ( ) ; while ( N % 2 == 0 ) { if ( primef . containsKey ( 2 ) ) { primef . put ( 2 , primef . get ( 2 ) + 1 ) ; } else { primef . put ( 2 , 1 ) ; } N = N / 2 ; } for ( int i = 3 ; i <= Math . sqrt ( N ) ; i ++ ) { while ( N % i == 0 ) { if ( primef . containsKey ( i ) ) { primef . put ( i , primef . get ( i ) + 1 ) ; } else { primef . put ( i , 1 ) ; } N = N / 2 ; } } if ( N > 2 ) { primef . put ( N , 1 ) ; } return primef ; } static int CountToMakeEqual ( int X , int Y ) { int gcdofXY = gcd ( X , Y ) ; int newX = Y / gcdofXY ; int newY = X / gcdofXY ; HashMap < Integer , Integer > primeX = PrimeFactor ( newX ) ; HashMap < Integer , Integer > primeY = PrimeFactor ( newY ) ; int ans = 0 ; for ( Map . Entry keys : primeX . entrySet ( ) ) { if ( X % ( int ) keys . getKey ( ) != 0 ) { return - 1 ; } ans += primeX . get ( keys . getKey ( ) ) ; } for ( Map . Entry keys : primeY . entrySet ( ) ) { if ( Y % ( int ) keys . getKey ( ) != 0 ) { return - 1 ; } ans += primeY . get ( keys . getKey ( ) ) ; } return ans ; } public static void main ( String [ ] args ) { int X = 36 ; int Y = 48 ; int ans = CountToMakeEqual ( X , Y ) ; System . out . println ( ans ) ; } }

Accumulator variables: ans, i
Iterator variables: i
Class/struct names: Main
Java program:
import java . io . * ; import java . lang . * ; import java . util . * ; class GFG { static class Node { int L , R , V ; Node ( int L , int R , int V ) { this . L = L ; this . R = R ; this . V = V ; } } static boolean check ( ArrayList < Integer > Adj [ ] , int Src , int N , boolean visited [ ] ) { int color [ ] = new int [ N ] ; visited [ Src ] = true ; ArrayDeque < Integer > q = new ArrayDeque < > ( ) ; q . addLast ( Src ) ; while ( ! q . isEmpty ( ) ) { int u = q . removeFirst ( ) ; int Col = color [ u ] ; for ( int x : Adj [ u ] ) { if ( visited [ x ] == true && color [ x ] == Col ) { return false ; } else if ( visited [ x ] == false ) { visited [ x ] = true ; q . addLast ( x ) ; color [ x ] = 1 - Col ; } } } return true ; } static void addEdge ( ArrayList < Integer > Adj [ ] , int u , int v ) { Adj [ u ] . add ( v ) ; Adj [ v ] . add ( u ) ; } static void isPossible ( Node Arr [ ] , int N ) { @ SuppressWarnings ( " unchecked " ) ArrayList < Integer > [ ] Adj = ( ArrayList < Integer > [ ] ) new ArrayList [ N ] ; for ( int i = 0 ; i < N ; i ++ ) Adj [ i ] = new ArrayList < > ( ) ; for ( int i = 0 ; i < N - 1 ; i ++ ) { for ( int j = i + 1 ; j < N ; j ++ ) { if ( Arr [ i ] . R < Arr [ j ] . L Arr [ i ] . L > Arr [ j ] . R ) { continue ; } else { if ( Arr [ i ] . V == Arr [ j ] . V ) { addEdge ( Adj , i , j ) ; } } } } boolean visited [ ] = new boolean [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { if ( visited [ i ] == false && Adj [ i ] . size ( ) > 0 ) { if ( check ( Adj , i , N , visited ) == false ) { System . out . println ( " No " ) ; return ; } } } System . out . println ( " Yes " ) ; } public static void main ( String [ ] args ) { Node arr [ ] = { new Node ( 5 , 7 , 2 ) , new Node ( 4 , 6 , 1 ) , new Node ( 1 , 5 , 2 ) , new Node ( 6 , 5 , 1 ) } ; int N = arr . length ; isPossible ( arr , N ) ; } }

Index/key variables: N, Src, i, j, u, v, x
Accumulator variables: i, j
Iterator variables: i, j, x
Class/struct names: GFG, Node
Java program:
import java . io . * ; import java . util . * ; class GFG { public static void lexNumbers ( int n ) { List < Integer > sol = new ArrayList < > ( ) ; dfs ( 1 , n , sol ) ; System . out . println ( sol ) ; } public static void dfs ( int temp , int n , List < Integer > sol ) { if ( temp > n ) return ; sol . add ( temp ) ; dfs ( temp * 10 , n , sol ) ; if ( temp % 10 != 9 ) dfs ( temp + 1 , n , sol ) ; } public static void main ( String [ ] args ) { int n = 15 ; lexNumbers ( n ) ; } }

Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GfG { static int minimumSwaps ( int [ ] arr ) { int count = 0 ; int i = 0 ; while ( i < arr . length ) { if ( arr [ i ] != i + 1 ) { while ( arr [ i ] != i + 1 ) { int temp = 0 ; temp = arr [ arr [ i ] - 1 ] ; arr [ arr [ i ] - 1 ] = arr [ i ] ; arr [ i ] = temp ; count ++ ; } } i ++ ; } return count ; } public static void main ( String [ ] args ) { int arr [ ] = { 2 , 3 , 4 , 1 , 5 } ; System . out . println ( minimumSwaps ( arr ) ) ; } }

Index/key variables: i
Accumulator variables: count, i
Class/struct names: GfG