dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
import java . io . * ; import java . util . * ; public class GFG { static void rearrange ( int [ ] a ) { int i = 0 , j = a . length - 1 ; int min = 0 , k , x = 0 , temp ; while ( i < j ) { for ( k = i ; k <= j ; k ++ ) { if ( a [ k ] < a [ min ] ) min = k ; } if ( x % 2 == 0 ) { temp = a [ i ] ; a [ i ] = a [ min ] ; a [ min ] = temp ; i ++ ; min = i ; } else { temp = a [ j ] ; a [ j ] = a [ min ] ; a [ min ] = temp ; j -- ; min = j ; } x ++ ; } for ( i = 0 ; i < a . length ; i ++ ) System . out . print ( a [ i ] + " ▁ " ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 3 , 3 , 4 , 5 } ; rearrange ( arr ) ; } }

Index/key variables: i, j, k, min
Accumulator variables: i, j, k, x
Iterator variables: i, k
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void redistribute ( Integer arr [ ] , int n , int x ) { Arrays . sort ( arr , Collections . reverseOrder ( ) ) ; int i , sum = 0 ; for ( i = 0 ; i < n ; i ++ ) { sum += arr [ i ] ; if ( sum / ( i + 1 ) < x ) { System . out . print ( i + "NEW_LINE"); break ; } } if ( i == n ) System . out . print ( n + "NEW_LINE"); } public static void main ( String [ ] args ) { Integer arr [ ] = { 5 , 1 , 2 , 1 } ; int x = 3 ; redistribute ( arr , 4 , x ) ; } }

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . Collections ; import java . util . * ; class GFG { static public int final_element ( Integer [ ] arr , int n ) { if ( arr == null ) { return 0 ; } PriorityQueue < Integer > heap = new PriorityQueue < Integer > ( Collections . reverseOrder ( ) ) ; for ( int i = 0 ; i < n ; i ++ ) { heap . offer ( arr [ i ] ) ; } while ( heap . size ( ) > 1 ) { int X = heap . poll ( ) ; int Y = heap . poll ( ) ; if ( X != Y ) { int diff = Math . abs ( X - Y ) ; heap . offer ( diff ) ; } } return heap . size ( ) == 1 ? heap . poll ( ) : - 1 ; } public static void main ( String [ ] args ) { Integer arr [ ] = new Integer [ ] { 3 , 5 , 2 , 7 } ; int n = arr . length ; System . out . println ( final_element ( arr , n ) ) ; } }

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

Index/key variables: N, i, l, r
Accumulator variables: ans, l, r
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { public static Vector < Integer > findFactors ( int n , int k ) { Vector < Integer > factors = new Vector < Integer > ( ) ; for ( int i = 1 ; i <= Math . sqrt ( k ) ; i ++ ) { if ( k % i == 0 ) { if ( k / i == i && i <= n ) factors . add ( i ) ; else { if ( i <= n ) factors . add ( i ) ; if ( k / i <= n ) factors . add ( k / i ) ; } } } return factors ; } public static Vector < Integer > findDigitSum ( Vector < Integer > a ) { for ( int i = 0 ; i < a . size ( ) ; i ++ ) { int c = 0 ; while ( a . get ( i ) > 0 ) { c += ( a . get ( i ) % 10 ) ; a . set ( i , ( a . get ( i ) / 10 ) ) ; } a . set ( i , c ) ; } return a ; } public static int findMMaxDistinctDigitSum ( Vector < Integer > distinctDigitSum , int m ) { int sum = 0 ; for ( int i = distinctDigitSum . size ( ) - 1 ; i >= 0 && m > 0 ; i -- , m -- ) sum += distinctDigitSum . get ( i ) ; return sum ; } public static int findDistinctMnumbers ( int n , int k , int m ) { Vector < Integer > factors = findFactors ( n , k ) ; Vector < Integer > digitSum = findDigitSum ( factors ) ; Collections . sort ( digitSum ) ; HashSet < Integer > hs1 = new HashSet < Integer > ( digitSum ) ; Vector < Integer > vect2 = new Vector < Integer > ( hs1 ) ; return findMMaxDistinctDigitSum ( vect2 , m ) ; } public static void main ( String args [ ] ) { int n = 100 , k = 80 , m = 4 ; System . out . println ( findDistinctMnumbers ( n , k , m ) ) ; } }

Accumulator variables: c, i, m, sum
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int partition ( Vector < String > objects , int l , int r , Map < String , Integer > hash ) { int j = l - 1 ; int last_element = hash . get ( objects . get ( r ) ) ; for ( int i = l ; i < r ; i ++ ) { if ( hash . get ( objects . get ( i ) ) <= last_element ) { j ++ ; Collections . swap ( objects , i , j ) ; } } j ++ ; Collections . swap ( objects , j , r ) ; return j ; } static void quicksort ( Vector < String > objects , int l , int r , Map < String , Integer > hash ) { if ( l < r ) { int mid = partition ( objects , l , r , hash ) ; quicksort ( objects , l , mid - 1 , hash ) ; quicksort ( objects , mid + 1 , r , hash ) ; } } static void sortObj ( Vector < String > objects ) { Map < String , Integer > hash = new HashMap < > ( ) ; hash . put ( " blue " , 1 ) ; hash . put ( " red " , 2 ) ; hash . put ( " yellow " , 3 ) ; quicksort ( objects , 0 , objects . size ( ) - 1 , hash ) ; for ( int i = 0 ; i < objects . size ( ) ; i ++ ) System . out . print ( objects . get ( i ) + " ▁ " ) ; } public static void main ( String [ ] args ) { Vector < String > objects = new Vector < > ( Arrays . asList ( " red " , " blue " , " red " , " yellow " , " blue " ) ) ; sortObj ( objects ) ; } }

Accumulator variables: i, j
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int getMax ( int inputArray [ ] ) { int maxValue = inputArray [ 0 ] ; for ( int i = 1 ; i < inputArray . length ; i ++ ) { if ( inputArray [ i ] > maxValue ) { maxValue = inputArray [ i ] ; } } return maxValue ; } static int minSteps ( int arr [ ] , int n ) { int maxVal = getMax ( arr ) ; return maxVal ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 4 } ; int n = arr . length ; System . out . println ( minSteps ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int maxWater ( int height [ ] , int n ) { int max = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { int current = ( Math . min ( height [ i ] , height [ j ] ) * ( j - i - 1 ) ) ; max = Math . max ( max , current ) ; } } return max ; } public static void main ( String [ ] args ) { int height [ ] = { 2 , 1 , 3 , 4 , 6 , 5 } ; int n = height . length ; System . out . print ( maxWater ( height , n ) ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . Arrays ; class Pair implements Comparable < Pair > { int ind , val ; Pair ( int ind , int val ) { this . ind = ind ; this . val = val ; } @ Override public int compareTo ( Pair o ) { if ( this . val > o . val ) return 1 ; return - 1 ; } } class GFG { static int maxWater ( int height [ ] , int n ) { Pair pairs [ ] = new Pair [ n ] ; for ( int i = 0 ; i < n ; i ++ ) pairs [ i ] = new Pair ( i , height [ i ] ) ; Arrays . sort ( pairs ) ; int minIndSoFar = pairs [ n - 1 ] . ind ; int maxIndSoFar = pairs [ n - 1 ] . ind ; int max = 0 ; for ( int i = n - 2 ; i >= 0 ; i -- ) { int left = 0 ; if ( minIndSoFar < pairs [ i ] . ind ) { left = ( pairs [ i ] . val * ( pairs [ i ] . ind - minIndSoFar - 1 ) ) ; } int right = 0 ; if ( maxIndSoFar > pairs [ i ] . ind ) { right = ( pairs [ i ] . val * ( maxIndSoFar - pairs [ i ] . ind - 1 ) ) ; } max = Math . max ( left , Math . max ( right , max ) ) ; minIndSoFar = Math . min ( minIndSoFar , pairs [ i ] . ind ) ; maxIndSoFar = Math . max ( maxIndSoFar , pairs [ i ] . ind ) ; } return max ; } public static void main ( String [ ] args ) { int height [ ] = { 2 , 1 , 3 , 4 , 6 , 5 } ; int n = height . length ; System . out . print ( maxWater ( height , n ) ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG, Pair
Java program:
import java . util . * ; class GFG { static int max_element ( int a [ ] ) { int m = a [ 0 ] ; for ( int i = 0 ; i < a . length ; i ++ ) m = Math . max ( a [ i ] , m ) ; return m ; } static boolean checkDivisors ( int a [ ] , int n ) { int X = max_element ( a ) ; Vector < Integer > b = new Vector < Integer > ( ) ; for ( int i = 1 ; i * i <= X ; i ++ ) { if ( X % i == 0 ) { b . add ( i ) ; if ( X / i != i ) b . add ( X / i ) ; } } if ( b . size ( ) != n ) return false ; Arrays . sort ( a ) ; Collections . sort ( b ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( b . get ( i ) != a [ i ] ) return false ; } return true ; } public static void main ( String args [ ] ) { int arr [ ] = { 8 , 1 , 2 , 12 , 48 , 6 , 4 , 24 , 16 , 3 } ; int N = arr . length ; if ( checkDivisors ( arr , N ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static class pair { int first , second ; pair ( int a , int b ) { first = a ; second = b ; } } static void findKthNode ( int u [ ] , int v [ ] , int n , int val [ ] , int V , int k ) { Vector < Vector < pair > > g = new Vector < Vector < pair > > ( ) ; for ( int i = 0 ; i < V ; i ++ ) g . add ( new Vector < pair > ( ) ) ; for ( int i = 0 ; i < n ; i ++ ) { g . get ( u [ i ] ) . add ( new pair ( val [ v [ i ] ] , v [ i ] ) ) ; g . get ( v [ i ] ) . add ( new pair ( val [ u [ i ] ] , u [ i ] ) ) ; } for ( int i = 0 ; i < V ; i ++ ) { if ( g . get ( i ) . size ( ) > 0 ) Collections . sort ( g . get ( i ) , new Comparator < pair > ( ) { public int compare ( pair p1 , pair p2 ) { return p1 . first - p2 . first ; } } ) ; if ( k <= g . get ( i ) . size ( ) ) System . out . printf ( "%dNEW_LINE", g.get(i).get(g.get(i).size() - k).second); else System . out . printf ( "-1NEW_LINE"); } return ; } public static void main ( String args [ ] ) { int V = 3 ; int val [ ] = { 2 , 4 , 3 } ; int u [ ] = { 0 , 0 , 1 } ; int v [ ] = { 2 , 1 , 2 } ; int n = u . length ; int k = 2 ; findKthNode ( u , v , n , val , V , k ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG, pair
Java program:
import java . util . * ; class GFG { static int mod ( int x ) { if ( x >= 0 ) return x ; return - x ; } static void findSquare ( int n ) { int points [ ] [ ] = { { 1 , 2 } , { - 3 , 4 } , { 1 , 78 } , { - 3 , - 7 } } ; int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { int x , y ; x = points [ i ] [ 0 ] ; y = points [ i ] [ 1 ] ; a [ i ] = Math . max ( mod ( x ) , mod ( y ) ) ; } Arrays . sort ( a ) ; int index = ( int ) ( Math . floor ( n / 2 ) - 1 ) ; System . out . println ( " Minimum ▁ M ▁ required ▁ is : ▁ " + a [ index ] ) ; } public static void main ( String [ ] args ) { int N ; N = 4 ; findSquare ( N ) ; } }

Index/key variables: i, index, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void findpath ( int [ ] [ ] graph , int n ) { Vector < Integer > numofadj = new Vector < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) numofadj . add ( accumulate ( graph [ i ] , 0 ) ) ; int startPoint = 0 , numofodd = 0 ; for ( int i = n - 1 ; i >= 0 ; i -- ) { if ( numofadj . elementAt ( i ) % 2 == 1 ) { numofodd ++ ; startPoint = i ; } } if ( numofodd > 2 ) { System . out . println ( " No ▁ Solution " ) ; return ; } Stack < Integer > stack = new Stack < > ( ) ; Vector < Integer > path = new Vector < > ( ) ; int cur = startPoint ; while ( ! stack . isEmpty ( ) || accumulate ( graph [ cur ] , 0 ) != 0 ) { if ( accumulate ( graph [ cur ] , 0 ) == 0 ) { path . add ( cur ) ; cur = stack . pop ( ) ; } else { for ( int i = 0 ; i < n ; i ++ ) { if ( graph [ cur ] [ i ] == 1 ) { stack . add ( cur ) ; graph [ cur ] [ i ] = 0 ; graph [ i ] [ cur ] = 0 ; cur = i ; break ; } } } } for ( int ele : path ) System . out . print ( ele + " ▁ - > ▁ " ) ; System . out . println ( cur ) ; } static int accumulate ( int [ ] arr , int sum ) { for ( int i : arr ) sum += i ; return sum ; } public static void main ( String [ ] args ) { int [ ] [ ] graph1 = { { 0 , 1 , 0 , 0 , 1 } , { 1 , 0 , 1 , 1 , 0 } , { 0 , 1 , 0 , 1 , 0 } , { 0 , 1 , 1 , 0 , 0 } , { 1 , 0 , 0 , 0 , 0 } } ; int n = graph1 . length ; findpath ( graph1 , n ) ; int [ ] [ ] graph2 = { { 0 , 1 , 0 , 1 , 1 } , { 1 , 0 , 1 , 0 , 1 } , { 0 , 1 , 0 , 1 , 1 } , { 1 , 1 , 1 , 0 , 0 } , { 1 , 0 , 1 , 0 , 0 } } ; n = graph2 . length ; findpath ( graph2 , n ) ; int [ ] [ ] graph3 = { { 0 , 1 , 0 , 0 , 1 } , { 1 , 0 , 1 , 1 , 1 } , { 0 , 1 , 0 , 1 , 0 } , { 0 , 1 , 1 , 0 , 1 } , { 1 , 1 , 0 , 1 , 0 } } ; n = graph3 . length ; findpath ( graph3 , n ) ; } }

Index/key variables: cur, i
Accumulator variables: i, numofodd, sum
Iterator variables: ele, i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int minSum ( int arr [ ] , int n ) { Arrays . sort ( arr ) ; int x = arr [ ( int ) n / 2 ] ; int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) sum += Math . abs ( arr [ i ] - x ) ; return sum ; } public static void main ( String args [ ] ) { int arr [ ] = { 1 , 3 , 9 , 3 , 6 } ; int n = arr . length ; System . out . println ( minSum ( 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 odd_even ( int arr [ ] , int n ) { Vector < Integer > odd_indexes = new Vector < Integer > ( ) ; Vector < Integer > even_indexes = new Vector < Integer > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( i % 2 == 0 ) odd_indexes . add ( arr [ i ] ) ; else even_indexes . add ( arr [ i ] ) ; } Collections . sort ( odd_indexes ) ; Collections . sort ( even_indexes ) ; for ( int i = 0 ; i < odd_indexes . size ( ) ; i ++ ) System . out . print ( odd_indexes . get ( i ) + " ▁ " ) ; for ( int i = 0 ; i < even_indexes . size ( ) ; i ++ ) System . out . print ( even_indexes . get ( i ) + " ▁ " ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 3 , 2 , 7 , 6 , 8 } ; int n = arr . length ; odd_even ( arr , n ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . TreeMap ; class Count { static int countPairs ( int [ ] a , int n ) { TreeMap < Integer , Integer > map = new TreeMap < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { map . put ( a [ i ] , 1 ) ; } int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( map . get ( a [ i ] ) < 1 ) continue ; int cur = 1 ; while ( cur <= a [ i ] ) cur <<= 1 ; if ( map . containsKey ( cur - a [ i ] ) ) { if ( cur - a [ i ] == a [ i ] && map . get ( a [ i ] ) == 1 ) continue ; count ++ ; map . put ( cur - a [ i ] , map . get ( cur - a [ i ] ) - 1 ) ; map . put ( a [ i ] , map . get ( a [ i ] ) - 1 ) ; } } return count ; } public static void main ( String [ ] args ) { int [ ] a = { 3 , 11 , 14 , 5 , 13 } ; int n = a . length ; System . out . println ( countPairs ( a , n ) ) ; } }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Class/struct names: Count
Java program:
import java . util . * ; class GFG { static int countMaxPos ( int [ ] arr ) { int n = arr . length ; HashMap < Integer , Integer > map = new HashMap < Integer , Integer > ( ) ; for ( int x : arr ) { if ( map . containsKey ( x ) ) map . put ( x , map . get ( x ) + 1 ) ; else map . put ( x , 1 ) ; } int max_freq = 0 ; for ( Map . Entry entry : map . entrySet ( ) ) max_freq = Math . max ( max_freq , ( int ) entry . getValue ( ) ) ; return n - max_freq ; } public static void main ( String [ ] args ) { int [ ] arr = { 20 , 30 , 10 , 50 , 40 } ; System . out . println ( countMaxPos ( arr ) ) ; } }

Iterator variables: x
Class/struct names: GFG
Java program:
import java . io . * ; import java . lang . * ; import java . util . * ; class GFG { static void anyPermutation ( int A [ ] , int B [ ] , int n ) { ArrayList < int [ ] > Ap = new ArrayList < > ( ) ; ArrayList < int [ ] > Bp = new ArrayList < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) Ap . add ( new int [ ] { A [ i ] , i } ) ; for ( int i = 0 ; i < n ; i ++ ) Bp . add ( new int [ ] { B [ i ] , i } ) ; Collections . sort ( Ap , ( x , y ) -> { if ( x [ 0 ] != y [ 0 ] ) return x [ 0 ] - y [ 0 ] ; return y [ 1 ] - y [ 1 ] ; } ) ; Collections . sort ( Bp , ( x , y ) -> { if ( x [ 0 ] != y [ 0 ] ) return x [ 0 ] - y [ 0 ] ; return y [ 1 ] - y [ 1 ] ; } ) ; int i = 0 , j = 0 ; int ans [ ] = new int [ n ] ; ArrayList < Integer > remain = new ArrayList < > ( ) ; while ( i < n && j < n ) { if ( Ap . get ( i ) [ 0 ] > Bp . get ( j ) [ 0 ] ) { ans [ Bp . get ( j ) [ 1 ] ] = Ap . get ( i ) [ 0 ] ; i ++ ; j ++ ; } else { remain . add ( i ) ; i ++ ; } } j = 0 ; for ( i = 0 ; i < n ; ++ i ) if ( ans [ i ] == 0 ) { ans [ i ] = Ap . get ( remain . get ( j ) ) [ 0 ] ; j ++ ; } for ( i = 0 ; i < n ; ++ i ) System . out . print ( ans [ i ] + " ▁ " ) ; } public static void main ( String [ ] args ) { int A [ ] = { 12 , 24 , 8 , 32 } ; int B [ ] = { 13 , 25 , 32 , 11 } ; int n = A . length ; anyPermutation ( A , B , n ) ; } }

Index/key variables: i, n
Accumulator variables: i, j
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . Collections ; import java . util . Vector ; class GFG { static void sortMultiples ( int arr [ ] , int n , int x ) { Vector < Integer > v = new Vector < Integer > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] % x == 0 ) { v . add ( arr [ i ] ) ; } } Collections . sort ( v ) ; int j = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] % x == 0 ) { arr [ i ] = v . get ( j ++ ) ; } } } public static void main ( String [ ] args ) { int arr [ ] = { 125 , 3 , 15 , 6 , 100 , 5 } ; int x = 5 ; int n = arr . length ; sortMultiples ( arr , n , x ) ; for ( int i = 0 ; i < n ; i ++ ) { System . out . print ( arr [ i ] + " ▁ " ) ; } } }

Index/key variables: i
Accumulator variables: i, j
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int minimumIncrease ( int a , int b , int c ) { int arr [ ] = { a , b , c } ; Arrays . sort ( arr ) ; if ( arr [ 0 ] + arr [ 1 ] >= arr [ 2 ] ) return 0 ; else return arr [ 2 ] - ( arr [ 0 ] + arr [ 1 ] ) ; } public static void main ( String [ ] args ) { int a = 3 , b = 5 , c = 10 ; System . out . println ( minimumIncrease ( a , b , c ) ) ; } }

Class/struct names: GFG
Java program:
import java . lang . * ; import java . util . * ; public class GFG { static int absSumDidd ( int a [ ] ) { Arrays . sort ( a ) ; int midValue = a [ a . length / 2 ] ; int sum = 0 ; for ( int i = 0 ; i < a . length ; i ++ ) { sum = sum + Math . abs ( a [ i ] - midValue ) ; } return sum ; } public static void main ( String [ ] args ) { int arr [ ] = { 5 , 11 , 14 , 10 , 17 , 15 } ; System . out . print ( absSumDidd ( arr ) ) ; }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static void printRLE ( String s ) { for ( int i = 0 ; i < s . length ( ) ; i ++ ) { int count = 1 ; while ( i + 1 < s . length ( ) && s . charAt ( i ) == s . charAt ( i + 1 ) ) { i ++ ; count ++ ; } System . out . print ( s . charAt ( i ) + " " + count + " ▁ " ) ; } System . out . println ( ) ; } public static void main ( String args [ ] ) { printRLE ( " GeeeEEKKKss " ) ; printRLE ( " ccccOddEEE " ) ; } }

Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int shortestChainLen ( String start , String target , Set < String > D ) { if ( start == target ) return 0 ; if ( ! D . contains ( target ) ) return 0 ; int level = 0 , wordlength = start . length ( ) ; Queue < String > Q = new LinkedList < > ( ) ; Q . add ( start ) ; while ( ! Q . isEmpty ( ) ) { ++ level ; int sizeofQ = Q . size ( ) ; for ( int i = 0 ; i < sizeofQ ; ++ i ) { char [ ] word = Q . peek ( ) . toCharArray ( ) ; Q . remove ( ) ; for ( int pos = 0 ; pos < wordlength ; ++ pos ) { char orig_char = word [ pos ] ; for ( char c = ' a ' ; c <= ' z ' ; ++ c ) { word [ pos ] = c ; if ( String . valueOf ( word ) . equals ( target ) ) return level + 1 ; if ( ! D . contains ( String . valueOf ( word ) ) ) continue ; D . remove ( String . valueOf ( word ) ) ; Q . add ( String . valueOf ( word ) ) ; } word [ pos ] = orig_char ; } } } return 0 ; } public static void main ( String [ ] args ) { Set < String > D = new HashSet < String > ( ) ; D . add ( " poon " ) ; D . add ( " plee " ) ; D . add ( " same " ) ; D . add ( " poie " ) ; D . add ( " plie " ) ; D . add ( " poin " ) ; D . add ( " plea " ) ; String start = " toon " ; String target = " plea " ; System . out . print ( " Length ▁ of ▁ shortest ▁ chain ▁ is : ▁ " + shortestChainLen ( start , target , D ) ) ; } }

Index/key variables: pos
Iterator variables: c, i, pos
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static class Node { int data ; Node left ; Node right ; Node ( int value ) { this . data = value ; } } ; static void inorder ( Node temp ) { if ( temp == null ) return ; inorder ( temp . left ) ; System . out . print ( temp . data + " ▁ " ) ; inorder ( temp . right ) ; } static void reverseTreePathUtil ( Node root , ArrayList < Node > path , int pathLen , int key ) { if ( root == null ) return ; path . set ( pathLen , root ) ; pathLen ++ ; if ( root . data == key ) { int i = 0 , j = pathLen - 1 ; while ( i < j ) { int temp = path . get ( i ) . data ; path . get ( i ) . data = path . get ( j ) . data ; path . get ( j ) . data = temp ; i ++ ; j -- ; } } if ( root . left == null && root . right == null ) return ; reverseTreePathUtil ( root . left , path , pathLen , key ) ; reverseTreePathUtil ( root . right , path , pathLen , key ) ; } static void reverseTreePath ( Node root , int key ) { if ( root == null ) return ; ArrayList < Node > path = new ArrayList < Node > ( ) ; for ( int i = 0 ; i < 50 ; i ++ ) { path . add ( null ) ; } reverseTreePathUtil ( root , path , 0 , key ) ; } public static void main ( String [ ] args ) { Node root = new Node ( 7 ) ; root . left = new Node ( 6 ) ; root . right = new Node ( 5 ) ; root . left . left = new Node ( 4 ) ; root . left . right = new Node ( 3 ) ; root . right . left = new Node ( 2 ) ; root . right . right = new Node ( 1 ) ; int key = 4 ; reverseTreePath ( root , key ) ; inorder ( root ) ; } }

Accumulator variables: i, j, pathLen
Iterator variables: i
Class/struct names: GFG, Node