dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
class GFG { static int maxSubarrayXOR ( int arr [ ] , int n ) { int ans = Integer . MIN_VALUE ; for ( int i = 0 ; i < n ; i ++ ) { int curr_xor = 0 ; for ( int j = i ; j < n ; j ++ ) { curr_xor = curr_xor ^ arr [ j ] ; ans = Math . max ( ans , curr_xor ) ; } } return ans ; } public static void main ( String args [ ] ) { int arr [ ] = { 8 , 1 , 2 , 12 } ; int n = arr . length ; System . out . println ( " Max ▁ subarray ▁ XOR ▁ is ▁ " + maxSubarrayXOR ( arr , n ) ) ; } }

Index/key variables: j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
class GFG { static int myAtoiRecursive ( String str , int n ) { if ( n == 1 ) { return str . charAt ( 0 ) - '0' ; } return ( 10 * myAtoiRecursive ( str , n - 1 ) + str . charAt ( n - 1 ) - '0' ) ; } public static void main ( String [ ] s ) { String str = "112" ; int n = str . length ( ) ; System . out . println ( myAtoiRecursive ( str , n ) ) ; } }

Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static void printPattern ( String str , int len ) { for ( int i = 0 ; i < len ; i ++ ) { for ( int j = 0 ; j < len ; j ++ ) { if ( ( i == j ) || ( i + j == len - 1 ) ) System . out . print ( str . charAt ( j ) ) ; else System . out . print ( " ▁ " ) ; } System . out . println ( ) ; } } public static void main ( String [ ] args ) { String str = " geeksforgeeks " ; int len = str . length ( ) ; printPattern ( str , len ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . Arrays ; class GFG { final static int MAX_CHARS = 26 ; static boolean isValid ( int count [ ] , int k ) { int val = 0 ; for ( int i = 0 ; i < MAX_CHARS ; i ++ ) { if ( count [ i ] > 0 ) { val ++ ; } } return ( k >= val ) ; } static void kUniques ( String s , int k ) { int u = 0 ; int n = s . length ( ) ; int count [ ] = new int [ MAX_CHARS ] ; Arrays . fill ( count , 0 ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( count [ s . charAt ( i ) - ' a ' ] == 0 ) { u ++ ; } count [ s . charAt ( i ) - ' a ' ] ++ ; } if ( u < k ) { System . out . print ( " Not ▁ enough ▁ unique ▁ characters " ) ; return ; } int curr_start = 0 , curr_end = 0 ; int max_window_size = 1 ; int max_window_start = 0 ; Arrays . fill ( count , 0 ) ; count [ s . charAt ( 0 ) - ' a ' ] ++ ; for ( int i = 1 ; i < n ; i ++ ) { count [ s . charAt ( i ) - ' a ' ] ++ ; curr_end ++ ; while ( ! isValid ( count , k ) ) { count [ s . charAt ( curr_start ) - ' a ' ] -- ; curr_start ++ ; } if ( curr_end - curr_start + 1 > max_window_size ) { max_window_size = curr_end - curr_start + 1 ; max_window_start = curr_start ; } } System . out . println ( " Max ▁ substring ▁ is ▁ : ▁ " + s . substring ( max_window_start , max_window_start + max_window_size ) + " ▁ with ▁ length ▁ " + max_window_size ) ; } static public void main ( String [ ] args ) { String s = " aabacbebebe " ; int k = 3 ; kUniques ( s , k ) ; } }

Index/key variables: MAX_CHARS, i
Accumulator variables: curr_end, curr_start, i, u, val
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int MAX_CHAR = 26 ; static int runCustomerSimulation ( int n , char [ ] seq ) { char [ ] seen = new char [ MAX_CHAR ] ; int res = 0 ; int occupied = 0 ; for ( int i = 0 ; i < seq . length ; i ++ ) { int ind = seq [ i ] - ' A ' ; if ( seen [ ind ] == 0 ) { seen [ ind ] = 1 ; if ( occupied < n ) { occupied ++ ; seen [ ind ] = 2 ; } else res ++ ; } else { if ( seen [ ind ] == 2 ) occupied -- ; seen [ ind ] = 0 ; } } return res ; } public static void main ( String [ ] args ) { System . out . println ( runCustomerSimulation ( 2 , " ABBAJJKZKZ " . toCharArray ( ) ) ) ; System . out . println ( runCustomerSimulation ( 3 , " GACCBDDBAGEE " . toCharArray ( ) ) ) ; System . out . println ( runCustomerSimulation ( 3 , " GACCBGDDBAEE " . toCharArray ( ) ) ) ; System . out . println ( runCustomerSimulation ( 1 , " ABCBCA " . toCharArray ( ) ) ) ; System . out . println ( runCustomerSimulation ( 1 , " ABCBCADEED " . toCharArray ( ) ) ) ; } }

Index/key variables: MAX_CHAR, i, ind
Accumulator variables: i, occupied, res
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static boolean canFormPalindrome ( String a ) { int bitvector = 0 , mask = 0 ; for ( int i = 0 ; i < a . length ( ) ; i ++ ) { int x = a . charAt ( i ) - ' a ' ; mask = 1 << x ; bitvector = bitvector ^ mask ; } return ( bitvector & ( bitvector - 1 ) ) == 0 ; } public static void main ( String [ ] args ) { if ( canFormPalindrome ( " geeksforgeeks " ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
public class GFG { static final int NO_OF_CHARS = 256 ; static boolean areAnagram ( String str1 , String str2 ) { int [ ] count = new int [ NO_OF_CHARS ] ; int i ; for ( i = 0 ; i < str1 . length ( ) && i < str2 . length ( ) ; i ++ ) { count [ str1 . charAt ( i ) ] ++ ; count [ str2 . charAt ( i ) ] -- ; } if ( str1 . length ( ) != str2 . length ( ) ) return false ; for ( i = 0 ; i < NO_OF_CHARS ; i ++ ) if ( count [ i ] != 0 ) return false ; return true ; } static void findAllAnagrams ( String arr [ ] , int n ) { for ( int i = 0 ; i < n ; i ++ ) for ( int j = i + 1 ; j < n ; j ++ ) if ( areAnagram ( arr [ i ] , arr [ j ] ) ) System . out . println ( arr [ i ] + " ▁ is ▁ anagram ▁ of ▁ " + arr [ j ] ) ; } public static void main ( String args [ ] ) { String arr [ ] = { " geeksquiz " , " geeksforgeeks " , " abcd " , " forgeeksgeeks " , " zuiqkeegs " } ; int n = arr . length ; findAllAnagrams ( arr , n ) ; } }

Index/key variables: NO_OF_CHARS, i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
class GFG { static int isPalindrome ( int n ) { int rev = 0 ; for ( int i = n ; i > 0 ; i /= 10 ) rev = rev * 10 + i % 10 ; return ( n == rev ) ? 1 : 0 ; } static void countPal ( int min , int max ) { for ( int i = min ; i <= max ; i ++ ) if ( isPalindrome ( i ) == 1 ) System . out . print ( i + " ▁ " ) ; } public static void main ( String args [ ] ) { countPal ( 100 , 2000 ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static String Minimum_Window ( char [ ] s , char [ ] t ) { int m [ ] = new int [ 256 ] ; int ans = Integer . MAX_VALUE ; int start = 0 ; int count = 0 ; for ( int i = 0 ; i < t . length ; i ++ ) { if ( m [ t [ i ] ] == 0 ) count ++ ; m [ t [ i ] ] ++ ; } int i = 0 ; int j = 0 ; while ( j < s . length ) { m [ s [ j ] ] -- ; if ( m [ s [ j ] ] == 0 ) count -- ; if ( count == 0 ) { while ( count == 0 ) { if ( ans > j - i + 1 ) { ans = Math . min ( ans , j - i + 1 ) ; start = i ; } m [ s [ i ] ] ++ ; if ( m [ s [ i ] ] > 0 ) count ++ ; i ++ ; } } j ++ ; } if ( ans != Integer . MAX_VALUE ) return String . valueOf ( s ) . substring ( start , ans + start ) ; else return " - 1" ; } public static void main ( String [ ] args ) { String s = " ADOBECODEBANC " ; String t = " ABC " ; System . out . print ( " - - > Smallest ▁ window ▁ that ▁ contain ▁ all ▁ character ▁ : ▁ " ) ; System . out . print ( Minimum_Window ( s . toCharArray ( ) , t . toCharArray ( ) ) ) ; } }

Index/key variables: i, j
Accumulator variables: count, i, j
Iterator variables: i
Class/struct names: GFG
Java program:
public class RunLength_Encoding { public static void printRLE ( String str ) { int n = str . length ( ) ; int count = 1 ; for ( int i = 1 ; i < n ; i ++ ) { if ( str . charAt ( i ) == str . charAt ( i - 1 ) ) { count ++ } else { System . out . print ( str . charAt ( i ) ) ; System . out . print ( count ) ; count = 1 } System . out . print ( str . charAt ( i ) ) ; System . out . print ( count ) ; } } public static void main ( String [ ] args ) { String str = " wwwwaaadexxxxxxywww " ; printRLE ( str ) ; } }

Accumulator variables: count, i
Iterator variables: i
Class/struct names: RunLength_Encoding
Java program:
class GFG { static final int NO_OF_CHARS = 256 ; static void print ( String [ ] list , String word , int list_size ) { int [ ] map = new int [ NO_OF_CHARS ] ; int i , j , count , word_size ; for ( i = 0 ; i < word . length ( ) ; i ++ ) map [ word . charAt ( i ) ] = 1 ; word_size = word . length ( ) ; for ( i = 0 ; i < list_size ; i ++ ) { for ( j = 0 , count = 0 ; j < list [ i ] . length ( ) ; j ++ ) { if ( map [ list [ i ] . charAt ( j ) ] > 0 ) { count ++ ; map [ list [ i ] . charAt ( j ) ] = 0 ; } } if ( count == word_size ) System . out . println ( list [ i ] ) ; for ( j = 0 ; j < word . length ( ) ; j ++ ) map [ word . charAt ( j ) ] = 1 ; } } public static void main ( String [ ] args ) { String str = " sun " ; String [ ] list = { " geeksforgeeks " , " unsorted " , " sunday " , " just " , " sss " } ; print ( list , str , 5 ) ; } }

Index/key variables: NO_OF_CHARS, i
Accumulator variables: count, i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
class GFG { static final int NO_OF_CHARS = 256 ; static char count [ ] = new char [ NO_OF_CHARS ] ; static void getCharCountArray ( String str ) { for ( int i = 0 ; i < str . length ( ) ; i ++ ) count [ str . charAt ( i ) ] ++ ; } static int firstNonRepeating ( String str ) { getCharCountArray ( str ) ; int index = - 1 , i ; for ( i = 0 ; i < str . length ( ) ; i ++ ) { if ( count [ str . charAt ( i ) ] == 1 ) { index = i ; break ; } } return index ; } public static void main ( String [ ] args ) { String str = " geeksforgeeks " ; int index = firstNonRepeating ( str ) ; System . out . println ( index == - 1 ? " Either ▁ all ▁ characters ▁ are ▁ repeating ▁ or ▁ string ▁ " + " is ▁ empty " : " First ▁ non - repeating ▁ character ▁ is ▁ " + str . charAt ( index ) ) ; } }

Index/key variables: NO_OF_CHARS
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static void divideString ( String str , int n ) { int str_size = str . length ( ) ; int part_size ; if ( str_size % n != 0 ) { System . out . println ( " Invalid ▁ Input : ▁ String ▁ size " + " is ▁ not ▁ divisible ▁ by ▁ n " ) ; return ; } part_size = str_size / n ; for ( int i = 0 ; i < str_size ; i ++ ) { if ( i % part_size == 0 ) System . out . println ( ) ; System . out . print ( str . charAt ( i ) ) ; } } public static void main ( String [ ] args ) { String str = " a _ simple _ divide _ string _ quest " ; divideString ( str , 4 ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static final String dictionary [ ] = { " GEEKS " , " FOR " , " QUIZ " , " GUQ " , " EE " } ; static final int n = dictionary . length ; static final int M = 3 , N = 3 ; static boolean isWord ( String str ) { for ( int i = 0 ; i < n ; i ++ ) if ( str . equals ( dictionary [ i ] ) ) return true ; return false ; } static void findWordsUtil ( char boggle [ ] [ ] , boolean visited [ ] [ ] , int i , int j , String str ) { visited [ i ] [ j ] = true ; str = str + boggle [ i ] [ j ] ; if ( isWord ( str ) ) System . out . println ( str ) ; for ( int row = i - 1 ; row <= i + 1 && row < M ; row ++ ) for ( int col = j - 1 ; col <= j + 1 && col < N ; col ++ ) if ( row >= 0 && col >= 0 && ! visited [ row ] [ col ] ) findWordsUtil ( boggle , visited , row , col , str ) ; str = " " + str . charAt ( str . length ( ) - 1 ) ; visited [ i ] [ j ] = false ; } static void findWords ( char boggle [ ] [ ] ) { boolean visited [ ] [ ] = new boolean [ M ] [ N ] ; String str = " " ; for ( int i = 0 ; i < M ; i ++ ) for ( int j = 0 ; j < N ; j ++ ) findWordsUtil ( boggle , visited , i , j , str ) ; } public static void main ( String args [ ] ) { char boggle [ ] [ ] = { { ' G ' , ' I ' , ' Z ' } , { ' U ' , ' E ' , ' K ' } , { ' Q ' , ' S ' , ' E ' } } ; System . out . println ( " Following ▁ words ▁ of ▁ dictionary ▁ are ▁ present " ) ; findWords ( boggle ) ; } }

Index/key variables: M, N, col, i, j, row
Accumulator variables: col, i, j, row
Iterator variables: col, i, j, row
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static class node { int data ; node left , right ; } ; static node newNode ( int key ) { node temp = new node ( ) ; temp . data = key ; temp . left = temp . right = null ; return ( temp ) ; } static void printLevelOrder ( node root ) { if ( root == null ) return ; Queue < node > q = new LinkedList < > ( ) ; q . add ( root ) ; while ( ! q . isEmpty ( ) ) { node temp = q . peek ( ) ; System . out . print ( temp . data + " ▁ " ) ; q . remove ( ) ; if ( temp . left != null ) { q . add ( temp . left ) ; } else if ( temp . right != null ) { System . out . print ( " null ▁ " ) ; } if ( temp . right != null ) { q . add ( temp . right ) ; } else if ( temp . left != null ) { System . out . print ( " null ▁ " ) ; } } } static node pruneTree ( node root ) { if ( root == null ) { return null ; } root . left = pruneTree ( root . left ) ; root . right = pruneTree ( root . right ) ; if ( root . data % 2 == 0 && root . right == null && root . left == null ) return null ; return root ; } public static void main ( String [ ] args ) { node root = newNode ( 1 ) ; root . left = newNode ( 2 ) ; root . left . left = newNode ( 8 ) ; root . left . right = newNode ( 10 ) ; root . right = newNode ( 7 ) ; root . right . left = newNode ( 12 ) ; root . right . right = newNode ( 5 ) ; node newRoot = pruneTree ( root ) ; printLevelOrder ( newRoot ) ; } }

Class/struct names: GFG, node
Java program:
class GFG { static int countWays ( int mtrx [ ] [ ] , int vrtx , int i , int dest , boolean visited [ ] ) { if ( i == dest ) { return 1 ; } int total = 0 ; for ( int j = 0 ; j < vrtx ; j ++ ) { if ( mtrx [ i ] [ j ] == 1 && ! visited [ j ] ) { visited [ j ] = true ; total += countWays ( mtrx , vrtx , j , dest , visited ) ; visited [ j ] = false ; } } return total ; } static int totalWays ( int mtrx [ ] [ ] , int vrtx , int src , int dest ) { boolean [ ] visited = new boolean [ vrtx ] ; for ( int i = 0 ; i < vrtx ; i ++ ) { visited [ i ] = false ; } visited [ src ] = true ; return countWays ( mtrx , vrtx , src , dest , visited ) ; } public static void main ( String [ ] args ) { int vrtx = 11 ; int mtrx [ ] [ ] = { { 0 , 1 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 } , { 1 , 0 , 1 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } , { 0 , 1 , 0 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } , { 0 , 1 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } , { 0 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 1 , 0 } , { 0 , 0 , 0 , 0 , 1 , 0 , 1 , 0 , 0 , 1 , 0 } , { 1 , 0 , 0 , 0 , 0 , 1 , 0 , 1 , 0 , 0 , 0 } , { 0 , 0 , 0 , 0 , 0 , 0 , 1 , 0 , 1 , 0 , 0 } , { 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 0 , 1 , 0 } , { 0 , 0 , 0 , 0 , 1 , 1 , 0 , 0 , 1 , 0 , 0 } , { 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 0 } } ; int src = 3 ; int dest = 9 ; System . out . print ( totalWays ( mtrx , vrtx , src - 1 , dest - 1 ) ) ; } }

Index/key variables: i, j, src, vrtx
Accumulator variables: i, j, total
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void printExistPath ( Stack < Integer > sx , Stack < Integer > sy , int last ) { if ( sx . isEmpty ( ) || sy . isEmpty ( ) ) { return ; } int x = sx . peek ( ) ; int y = sy . peek ( ) ; sx . pop ( ) ; sy . pop ( ) ; printExistPath ( sx , sy , last ) ; if ( sx . size ( ) == last - 1 ) { System . out . print ( " ( " + x + " , ▁ " + y + " ) " ) ; } else { System . out . print ( " ( " + x + " , ▁ " + y + " ) - > " ) ; } } static boolean storePath ( int srcX , int srcY , int destX , int destY , Stack < Integer > sx , Stack < Integer > sy ) { if ( srcX > destX srcY > destY ) { return false ; } sx . add ( srcX ) ; sy . add ( srcY ) ; if ( srcX == destX && srcY == destY ) { printExistPath ( sx , sy , sx . size ( ) ) ; return true ; } if ( storePath ( ( 2 * srcX ) + srcY , srcY , destX , destY , sx , sy ) ) { return true ; } if ( storePath ( srcX , ( 2 * srcY ) + srcX , destX , destY , sx , sy ) ) { return true ; } sx . pop ( ) ; sy . pop ( ) ; return false ; } static boolean isPathExist ( int srcX , int srcY , int destX , int destY ) { Stack < Integer > sx = new Stack < Integer > ( ) ; Stack < Integer > sy = new Stack < Integer > ( ) ; return storePath ( srcX , srcY , destX , destY , sx , sy ) ; } static void printPath ( int srcX , int srcY , int destX , int destY ) { if ( ! isPathExist ( srcX , srcY , destX , destY ) ) { System . out . print ( " - 1" ) ; } } public static void main ( String [ ] args ) { int srcX = 5 , srcY = 8 ; int destX = 83 , destY = 21 ; printPath ( srcX , srcY , destX , destY ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static class Node { int key ; Node left , right ; } ; static Node newNode ( int key ) { Node temp = new Node ( ) ; temp . key = key ; temp . left = temp . right = null ; return ( temp ) ; } static int evenPaths ( Node node , int count ) { if ( node == null || ( node . key % 2 != 0 ) ) { return count ; } if ( node . left == null && node . right == null ) { count ++ ; } count = evenPaths ( node . left , count ) ; return evenPaths ( node . right , count ) ; } static int countEvenPaths ( Node node ) { return evenPaths ( node , 0 ) ; } public static void main ( String args [ ] ) { Node root = newNode ( 12 ) ; root . left = newNode ( 13 ) ; root . right = newNode ( 12 ) ; root . right . left = newNode ( 14 ) ; root . right . right = newNode ( 16 ) ; root . right . left . left = newNode ( 21 ) ; root . right . left . right = newNode ( 22 ) ; root . right . right . left = newNode ( 22 ) ; root . right . right . right = newNode ( 24 ) ; root . right . right . right . left = newNode ( 8 ) ; System . out . println ( countEvenPaths ( root ) ) ; } }

Accumulator variables: count
Class/struct names: GFG, Node
Java program:
import java . util . * ; class GFG { static Vector < Integer > c = new Vector < > ( ) ; static int ans = 0 ; static void subsetSum ( int i , int curr ) { if ( i == c . size ( ) ) { ans += curr ; return ; } subsetSum ( i + 1 , curr + c . elementAt ( i ) ) ; subsetSum ( i + 1 , curr ) ; } static void subsetGen ( int [ ] arr , int i , int n ) { if ( i == n ) { subsetSum ( 0 , 0 ) ; return ; } subsetGen ( arr , i + 1 , n ) ; c . add ( arr [ i ] ) ; subsetGen ( arr , i + 1 , n ) ; c . remove ( c . size ( ) - 1 ) ; } public static void main ( String [ ] args ) { int [ ] arr = { 1 , 1 } ; int n = arr . length ; subsetGen ( arr , 0 , n ) ; System . out . println ( ans ) ; } }

Index/key variables: i
Accumulator variables: ans
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { static int N = 1000 ; static ArrayList < ArrayList < Integer > > adj = new ArrayList < ArrayList < Integer > > ( ) ; static void dfsUtil ( int u , int node , boolean visited [ ] , ArrayList < ArrayList < Integer > > road_used , int parent , int it ) { int c = 0 ; for ( int i = 0 ; i < node ; i ++ ) if ( visited [ i ] ) c ++ ; if ( c == node ) return ; visited [ u ] = true ; road_used . add ( new ArrayList < Integer > ( Arrays . asList ( parent , u ) ) ) ; System . out . print ( u + " ▁ " ) ; for ( int x : adj . get ( u ) ) { if ( ! visited [ x ] ) { dfsUtil ( x , node , visited , road_used , u , it + 1 ) ; } } for ( int y = 0 ; y < road_used . size ( ) ; y ++ ) { if ( road_used . get ( y ) . get ( 1 ) == u ) { dfsUtil ( road_used . get ( y ) . get ( 0 ) , node , visited , road_used , u , it + 1 ) ; } } } static void dfs ( int node ) { boolean [ ] visited = new boolean [ node ] ; ArrayList < ArrayList < Integer > > road_used = new ArrayList < ArrayList < Integer > > ( ) ; for ( int i = 0 ; i < node ; i ++ ) { visited [ i ] = false ; } dfsUtil ( 0 , node , visited , road_used , - 1 , 0 ) ; } static void insertEdge ( int u , int v ) { adj . get ( u ) . add ( v ) ; adj . get ( v ) . add ( u ) ; } public static void main ( String [ ] args ) { int node = 11 , edge = 13 ; for ( int i = 0 ; i < N ; i ++ ) { adj . add ( new ArrayList < Integer > ( ) ) ; } insertEdge ( 0 , 1 ) ; insertEdge ( 0 , 2 ) ; insertEdge ( 1 , 5 ) ; insertEdge ( 1 , 6 ) ; insertEdge ( 2 , 4 ) ; insertEdge ( 2 , 9 ) ; insertEdge ( 6 , 7 ) ; insertEdge ( 6 , 8 ) ; insertEdge ( 7 , 8 ) ; insertEdge ( 2 , 3 ) ; insertEdge ( 3 , 9 ) ; insertEdge ( 3 , 10 ) ; insertEdge ( 9 , 10 ) ; dfs ( node ) ; } }

Index/key variables: i, node, u, x
Accumulator variables: c, i, y
Iterator variables: i, x, y
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static String max ; static void findMaximumNum ( char [ ] str , int k ) { if ( k == 0 ) return ; int n = str . length ; for ( int i = 0 ; i < n - 1 ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { if ( str [ i ] < str [ j ] ) { char t = str [ i ] ; str [ i ] = str [ j ] ; str [ j ] = t ; if ( String . valueOf ( str ) . compareTo ( max ) > 0 ) max = String . valueOf ( str ) ; findMaximumNum ( str , k - 1 ) ; char c = str [ i ] ; str [ i ] = str [ j ] ; str [ j ] = c ; } } } } public static void main ( String [ ] args ) { String str = "129814999" ; int k = 4 ; max = str ; findMaximumNum ( str . toCharArray ( ) , k ) ; System . out . print ( max + "NEW_LINE"); } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { static ArrayList < ArrayList < Integer > > allPaths = new ArrayList < ArrayList < Integer > > ( ) ; static void findPathsUtil ( ArrayList < ArrayList < Integer > > maze , int m , int n , int i , int j , ArrayList < Integer > path , int indx ) { if ( i == m - 1 ) { for ( int k = j ; k < n ; k ++ ) { path . set ( indx + k - j , maze . get ( i ) . get ( k ) ) ; } System . out . print ( " [ " + path . get ( 0 ) + " , ▁ " ) ; for ( int z = 1 ; z < path . size ( ) - 1 ; z ++ ) { System . out . print ( path . get ( z ) + " , ▁ " ) ; } System . out . println ( path . get ( path . size ( ) - 1 ) + " ] " ) ; allPaths . add ( path ) ; return ; } if ( j == n - 1 ) { for ( int k = i ; k < m ; k ++ ) { path . set ( indx + k - i , maze . get ( k ) . get ( j ) ) ; } System . out . print ( " [ " + path . get ( 0 ) + " , ▁ " ) ; for ( int z = 1 ; z < path . size ( ) - 1 ; z ++ ) { System . out . print ( path . get ( z ) + " , ▁ " ) ; } System . out . println ( path . get ( path . size ( ) - 1 ) + " ] " ) ; allPaths . add ( path ) ; return ; } path . set ( indx , maze . get ( i ) . get ( j ) ) ; findPathsUtil ( maze , m , n , i + 1 , j , path , indx + 1 ) ; findPathsUtil ( maze , m , n , i , j + 1 , path , indx + 1 ) ; } static void findPaths ( ArrayList < ArrayList < Integer > > maze , int m , int n ) { ArrayList < Integer > path = new ArrayList < Integer > ( ) ; for ( int i = 0 ; i < m + n - 1 ; i ++ ) { path . add ( 0 ) ; } findPathsUtil ( maze , m , n , 0 , 0 , path , 0 ) ; } public static void main ( String [ ] args ) { ArrayList < ArrayList < Integer > > maze = new ArrayList < ArrayList < Integer > > ( ) ; maze . add ( new ArrayList < Integer > ( Arrays . asList ( 1 , 2 , 3 ) ) ) ; maze . add ( new ArrayList < Integer > ( Arrays . asList ( 4 , 5 , 6 ) ) ) ; maze . add ( new ArrayList < Integer > ( Arrays . asList ( 7 , 8 , 9 ) ) ) ; findPaths ( maze , 3 , 3 ) ; } }

Accumulator variables: i, k, z
Iterator variables: i, k, z
Class/struct names: GFG
Java program:
class GFG { static boolean chkPair ( int A [ ] , int size , int x ) { for ( int i = 0 ; i < ( size - 1 ) ; i ++ ) { for ( int j = ( i + 1 ) ; j < size ; j ++ ) { if ( A [ i ] + A [ j ] == x ) { System . out . println ( " Pair ▁ with ▁ a ▁ given ▁ sum ▁ " + x + " ▁ is ▁ ( " + A [ i ] + " , ▁ " + A [ j ] + " ) " ) ; return true ; } } } return false ; } public static void main ( String [ ] args ) { int A [ ] = { 0 , - 1 , 2 , - 3 , 1 } ; int x = - 2 ; int size = A . length ; if ( chkPair ( A , size , x ) ) { System . out . println ( " Valid ▁ pair ▁ exists " ) ; } else { System . out . println ( " No ▁ valid ▁ pair ▁ exists ▁ for ▁ " + x ) ; } } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG