dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
import java . io . * ; class GFG { static void multiply ( int a [ ] [ ] , int b [ ] [ ] ) { int mul [ ] [ ] = new int [ 3 ] [ 3 ] ; for ( int i = 0 ; i < 3 ; i ++ ) { for ( int j = 0 ; j < 3 ; j ++ ) { mul [ i ] [ j ] = 0 ; for ( int k = 0 ; k < 3 ; k ++ ) mul [ i ] [ j ] += a [ i ] [ k ] * b [ k ] [ j ] ; } } for ( int i = 0 ; i < 3 ; i ++ ) for ( int j = 0 ; j < 3 ; j ++ ) a [ i ] [ j ] = mul [ i ] [ j ] ; } static int power ( int F [ ] [ ] , int n ) { int M [ ] [ ] = { { 1 , 1 , 1 } , { 1 , 0 , 0 } , { 0 , 1 , 0 } } ; if ( n == 1 ) return F [ 0 ] [ 0 ] + F [ 0 ] [ 1 ] ; power ( F , n / 2 ) ; multiply ( F , F ) ; if ( n % 2 != 0 ) multiply ( F , M ) ; return F [ 0 ] [ 0 ] + F [ 0 ] [ 1 ] ; } static int findNthTerm ( int n ) { int F [ ] [ ] = { { 1 , 1 , 1 } , { 1 , 0 , 0 } , { 0 , 1 , 0 } } ; return power ( F , n - 2 ) ; } public static void main ( String [ ] args ) { int n = 5 ; System . out . println ( " F ( 5 ) ▁ is ▁ " + findNthTerm ( n ) ) ; } }

Index/key variables: i, j, k
Accumulator variables: i, j, k
Iterator variables: i, j, k
Class/struct names: GFG
Java program:
import java . io . * ; class Grid { static int count ( int n ) { int [ ] dp = new int [ n + 1 ] ; dp [ 0 ] = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { if ( i >= 1 && i <= 3 ) dp [ i ] = 1 ; else if ( i == 4 ) dp [ i ] = 2 ; else { dp [ i ] = dp [ i - 1 ] + dp [ i - 4 ] ; } } return dp [ n ] ; } public static void main ( String [ ] args ) { int n = 5 ; System . out . println ( " Count ▁ of ▁ ways ▁ is : ▁ " + count ( n ) ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: Grid
Java program:
import java . io . * ; class GFG { static int countDer ( int n ) { if ( n == 1 n == 2 ) { return n - 1 ; } int a = 0 ; int b = 1 ; for ( int i = 3 ; i <= n ; ++ i ) { int cur = ( i - 1 ) * ( a + b ) ; a = b ; b = cur ; } return b ; } public static void main ( String [ ] args ) { int n = 4 ; System . out . println ( " Count ▁ of ▁ Dearrangements ▁ is ▁ " + countDer ( n ) ) ; } }

Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int bellNumber ( int n ) { int [ ] [ ] bell = new int [ n + 1 ] [ n + 1 ] ; bell [ 0 ] [ 0 ] = 1 ; for ( int i = 1 ; i <= n ; i ++ ) { bell [ i ] [ 0 ] = bell [ i - 1 ] [ i - 1 ] ; for ( int j = 1 ; j <= i ; j ++ ) bell [ i ] [ j ] = bell [ i - 1 ] [ j - 1 ] + bell [ i ] [ j - 1 ] ; } return bell [ n ] [ 0 ] ; } public static void main ( String [ ] args ) { for ( int n = 0 ; n <= 5 ; n ++ ) System . out . println ( " Bell ▁ Number ▁ " + n + " ▁ is ▁ " + bellNumber ( n ) ) ; } }

Index/key variables: i, j, n
Accumulator variables: i, j, n
Iterator variables: i, j, n
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int printCountDP ( int dist ) { int [ ] count = new int [ dist + 1 ] ; count [ 0 ] = 1 ; if ( dist >= 1 ) count [ 1 ] = 1 ; if ( dist >= 2 ) count [ 2 ] = 2 ; for ( int i = 3 ; i <= dist ; i ++ ) count [ i ] = count [ i - 1 ] + count [ i - 2 ] + count [ i - 3 ] ; return count [ dist ] ; } public static void main ( String [ ] args ) { int dist = 4 ; System . out . println ( printCountDP ( dist ) ) ; } }

Index/key variables: dist, i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int countSeq ( int n ) { int nCr = 1 , res = 1 ; for ( int r = 1 ; r <= n ; r ++ ) { nCr = ( nCr * ( n + 1 - r ) ) / r ; res += nCr * nCr ; } return res ; } public static void main ( String args [ ] ) { int n = 2 ; System . out . print ( " Count ▁ of ▁ sequences ▁ is ▁ " ) ; System . out . println ( countSeq ( n ) ) ; } }

Accumulator variables: r, res
Iterator variables: r
Class/struct names: GFG
Java program:
class GFG { static int min ( int a , int b ) { return ( a < b ) ? a : b ; } static int min ( int arr [ ] , int l , int h ) { int mn = arr [ l ] ; for ( int i = l + 1 ; i <= h ; i ++ ) { if ( mn > arr [ i ] ) { mn = arr [ i ] ; } } return mn ; } static int max ( int arr [ ] , int l , int h ) { int mx = arr [ l ] ; for ( int i = l + 1 ; i <= h ; i ++ ) { if ( mx < arr [ i ] ) { mx = arr [ i ] ; } } return mx ; } static int minRemovalsDP ( int arr [ ] , int n ) { int table [ ] [ ] = new int [ n ] [ n ] , gap , i , j , mn , mx ; for ( gap = 0 ; gap < n ; ++ gap ) { for ( i = 0 , j = gap ; j < n ; ++ i , ++ j ) { mn = min ( arr , i , j ) ; mx = max ( arr , i , j ) ; table [ i ] [ j ] = ( 2 * mn > mx ) ? 0 : min ( table [ i ] [ j - 1 ] + 1 , table [ i + 1 ] [ j ] + 1 ) ; } } return table [ 0 ] [ n - 1 ] ; } public static void main ( String [ ] args ) { int arr [ ] = { 20 , 4 , 1 , 3 } ; int n = arr . length ; System . out . println ( minRemovalsDP ( arr , n ) ) ; } }

Index/key variables: i, j, l, n
Accumulator variables: i
Iterator variables: gap, i
Class/struct names: GFG
Java program:
class GFG { static int numberOfPaths ( int m , int n ) { if ( m == 1 n == 1 ) return 1 ; return numberOfPaths ( m - 1 , n ) + numberOfPaths ( m , n - 1 ) ; } public static void main ( String args [ ] ) { System . out . println ( numberOfPaths ( 3 , 3 ) ) ; } }

Class/struct names: GFG
Java program:
class GFG { static int numberOfPaths ( int m , int n ) { int path = 1 ; for ( int i = n ; i < ( m + n - 1 ) ; i ++ ) { path *= i ; path /= ( i - n + 1 ) ; } return path ; } public static void main ( String [ ] args ) { System . out . println ( numberOfPaths ( 3 , 3 ) ) ; } }

Accumulator variables: i, path
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int lenghtOfLongestAP ( int set [ ] , int n ) { if ( n <= 2 ) return n ; int L [ ] [ ] = new int [ n ] [ n ] ; int llap = 2 ; for ( int i = 0 ; i < n ; i ++ ) L [ i ] [ n - 1 ] = 2 ; for ( int j = n - 2 ; j >= 1 ; j -- ) { int i = j - 1 , k = j + 1 ; while ( i >= 0 && k <= n - 1 ) { if ( set [ i ] + set [ k ] < 2 * set [ j ] ) k ++ ; else if ( set [ i ] + set [ k ] > 2 * set [ j ] ) { L [ i ] [ j ] = 2 ; i -- ; } else { L [ i ] [ j ] = L [ j ] [ k ] + 1 ; llap = Math . max ( llap , L [ i ] [ j ] ) ; i -- ; k ++ ; } } while ( i >= 0 ) { L [ i ] [ j ] = 2 ; i -- ; } } return llap ; } public static void main ( String [ ] args ) { int set1 [ ] = { 1 , 7 , 10 , 13 , 14 , 19 } ; int n1 = set1 . length ; System . out . println ( lenghtOfLongestAP ( set1 , n1 ) ) ; int set2 [ ] = { 1 , 7 , 10 , 15 , 27 , 29 } ; int n2 = set2 . length ; System . out . println ( lenghtOfLongestAP ( set2 , n2 ) ) ; int set3 [ ] = { 2 , 4 , 6 , 8 , 10 } ; int n3 = set3 . length ; System . out . println ( lenghtOfLongestAP ( set3 , n3 ) ) ; } }

Index/key variables: i, j, k, n
Accumulator variables: i, j, k
Iterator variables: i, j
Class/struct names: GFG
Java program:
public class GFG { static int optCost ( int freq [ ] , int i , int j ) { return 0 ; if ( j == i ) return freq [ i ] ; int fsum = sum ( freq , i , j ) ; int min = Integer . MAX_VALUE ; for ( int r = i ; r <= j ; ++ r ) { int cost = optCost ( freq , i , r - 1 ) + optCost ( freq , r + 1 , j ) ; if ( cost < min ) min = cost ; } return min + fsum ; } static int optimalSearchTree ( int keys [ ] , int freq [ ] , int n ) { return optCost ( freq , 0 , n - 1 ) ; } static int sum ( int freq [ ] , int i , int j ) { int s = 0 ; for ( int k = i ; k <= j ; k ++ ) s += freq [ k ] ; return s ; } public static void main ( String [ ] args ) { int keys [ ] = { 10 , 12 , 20 } ; int freq [ ] = { 34 , 8 , 50 } ; int n = keys . length ; System . out . println ( " Cost ▁ of ▁ Optimal ▁ BST ▁ is ▁ " + optimalSearchTree ( keys , freq , n ) ) ; } }

Index/key variables: i, k
Accumulator variables: k, s
Iterator variables: k, r
Class/struct names: GFG
Java program:
public class WordWrap { final int MAX = Integer . MAX_VALUE ; int printSolution ( int p [ ] , int n ) { int k ; if ( p [ n ] == 1 ) k = 1 ; else k = printSolution ( p , p [ n ] - 1 ) + 1 ; System . out . println ( " Line ▁ number " + " ▁ " + k + " : ▁ " + " From ▁ word ▁ no . " + " ▁ " + p [ n ] + " ▁ " + " to " + " ▁ " + n ) ; return k ; } void solveWordWrap ( int l [ ] , int n , int M ) { int extras [ ] [ ] = new int [ n + 1 ] [ n + 1 ] ; int lc [ ] [ ] = new int [ n + 1 ] [ n + 1 ] ; int c [ ] = new int [ n + 1 ] ; int p [ ] = new int [ n + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) { extras [ i ] [ i ] = M - l [ i - 1 ] ; for ( int j = i + 1 ; j <= n ; j ++ ) extras [ i ] [ j ] = extras [ i ] [ j - 1 ] - l [ j - 1 ] - 1 ; } for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = i ; j <= n ; j ++ ) { if ( extras [ i ] [ j ] < 0 ) lc [ i ] [ j ] = MAX ; else if ( j == n && extras [ i ] [ j ] >= 0 ) lc [ i ] [ j ] = 0 ; else lc [ i ] [ j ] = extras [ i ] [ j ] * extras [ i ] [ j ] ; } } c [ 0 ] = 0 ; for ( int j = 1 ; j <= n ; j ++ ) { c [ j ] = MAX ; for ( int i = 1 ; i <= j ; i ++ ) { if ( c [ i - 1 ] != MAX && lc [ i ] [ j ] != MAX && ( c [ i - 1 ] + lc [ i ] [ j ] < c [ j ] ) ) { c [ j ] = c [ i - 1 ] + lc [ i ] [ j ] ; p [ j ] = i ; } } } printSolution ( p , n ) ; } public static void main ( String args [ ] ) { WordWrap w = new WordWrap ( ) ; int l [ ] = { 3 , 2 , 2 , 5 } ; int n = l . length ; int M = 6 ; w . solveWordWrap ( l , n , M ) ; } }

Index/key variables: i, j, n
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: WordWrap
Java program:
public class GFG { static boolean isPalindrome ( String string , int i , int j ) { while ( i < j ) { if ( string . charAt ( i ) != string . charAt ( j ) ) return false ; i ++ ; j -- ; } return true ; } static int minPalPartion ( String string , int i , int j ) { if ( i >= j || isPalindrome ( string , i , j ) ) return 0 ; int ans = Integer . MAX_VALUE , count ; for ( int k = i ; k < j ; k ++ ) { count = minPalPartion ( string , i , k ) + minPalPartion ( string , k + 1 , j ) + 1 ; ans = Math . min ( ans , count ) ; } return ans ; } public static void main ( String args [ ] ) { String str = " ababbbabbababa " ; System . out . println ( " Min ▁ cuts ▁ needed ▁ for ▁ " + " Palindrome ▁ Partitioning ▁ is ▁ " + minPalPartion ( str , 0 , str . length ( ) - 1 ) ) ; } }

Accumulator variables: i, j, k
Iterator variables: k
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { public static int minCut ( String a ) { int [ ] cut = new int [ a . length ( ) ] ; boolean [ ] [ ] palindrome = new boolean [ a . length ( ) ] [ a . length ( ) ] ; for ( int i = 0 ; i < a . length ( ) ; i ++ ) { int minCut = i ; for ( int j = 0 ; j <= i ; j ++ ) { if ( a . charAt ( i ) == a . charAt ( j ) && ( i - j < 2 palindrome [ j + 1 ] [ i - 1 ] ) ) { palindrome [ j ] [ i ] = true ; minCut = Math . min ( minCut , j == 0 ? 0 : ( cut [ j - 1 ] + 1 ) ) ; } } cut [ i ] = minCut ; } return cut [ a . length ( ) - 1 ] ; } public static void main ( String [ ] args ) { System . out . println ( minCut ( " aab " ) ) ; System . out . println ( minCut ( " aabababaxx " ) ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; import java . lang . * ; import java . io . * ; class LBS { static int lbs ( int arr [ ] , int n ) { int i , j ; int [ ] lis = new int [ n ] ; for ( i = 0 ; i < n ; i ++ ) lis [ i ] = 1 ; for ( i = 1 ; i < n ; i ++ ) for ( j = 0 ; j < i ; j ++ ) if ( arr [ i ] > arr [ j ] && lis [ i ] < lis [ j ] + 1 ) lis [ i ] = lis [ j ] + 1 ; int [ ] lds = new int [ n ] ; for ( i = 0 ; i < n ; i ++ ) lds [ i ] = 1 ; for ( i = n - 2 ; i >= 0 ; i -- ) for ( j = n - 1 ; j > i ; j -- ) if ( arr [ i ] > arr [ j ] && lds [ i ] < lds [ j ] + 1 ) lds [ i ] = lds [ j ] + 1 ; int max = lis [ 0 ] + lds [ 0 ] - 1 ; for ( i = 1 ; i < n ; i ++ ) if ( lis [ i ] + lds [ i ] - 1 > max ) max = lis [ i ] + lds [ i ] - 1 ; return max ; } public static void main ( String [ ] args ) { int arr [ ] = { 0 , 8 , 4 , 12 , 2 , 10 , 6 , 14 , 1 , 9 , 5 , 13 , 3 , 11 , 7 , 15 } ; int n = arr . length ; System . out . println ( " Length ▁ of ▁ LBS ▁ is ▁ " + lbs ( arr , n ) ) ; } }

Index/key variables: i, j, n
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: LBS
Java program:
class EggDrop { static int max ( int a , int b ) { return ( a > b ) ? a : b ; } static int eggDrop ( int n , int k ) { int eggFloor [ ] [ ] = new int [ n + 1 ] [ k + 1 ] ; int res ; int i , j , x ; for ( i = 1 ; i <= n ; i ++ ) { eggFloor [ i ] [ 1 ] = 1 ; eggFloor [ i ] [ 0 ] = 0 ; } for ( j = 1 ; j <= k ; j ++ ) eggFloor [ 1 ] [ j ] = j ; for ( i = 2 ; i <= n ; i ++ ) { for ( j = 2 ; j <= k ; j ++ ) { eggFloor [ i ] [ j ] = Integer . MAX_VALUE ; for ( x = 1 ; x <= j ; x ++ ) { res = 1 + max ( eggFloor [ i - 1 ] [ x - 1 ] , eggFloor [ i ] [ j - x ] ) ; if ( res < eggFloor [ i ] [ j ] ) eggFloor [ i ] [ j ] = res ; } } } return eggFloor [ n ] [ k ] ; } public static void main ( String args [ ] ) { int n = 2 , k = 10 ; System . out . println ( " Minimum ▁ number ▁ of ▁ trials ▁ in ▁ worst " + " ▁ case ▁ with ▁ " + n + " ▁ eggs ▁ and ▁ " + k + " ▁ floors ▁ is ▁ " + eggDrop ( n , k ) ) ; } }

Index/key variables: i, j, k, n
Accumulator variables: i, j, x
Iterator variables: i, j, x
Class/struct names: EggDrop
Java program:
class Knapsack { static int max ( int a , int b ) { return ( a > b ) ? a : b ; } static int knapSack ( int W , int wt [ ] , int val [ ] , int n ) { if ( n == 0 W == 0 ) return 0 ; if ( wt [ n - 1 ] > W ) return knapSack ( W , wt , val , n - 1 ) ; else return max ( val [ n - 1 ] + knapSack ( W - wt [ n - 1 ] , wt , val , n - 1 ) , knapSack ( W , wt , val , n - 1 ) ) ; } public static void main ( String args [ ] ) { int val [ ] = new int [ ] { 60 , 100 , 120 } ; int wt [ ] = new int [ ] { 10 , 20 , 30 } ; int W = 50 ; int n = val . length ; System . out . println ( knapSack ( W , wt , val , n ) ) ; } }

Class/struct names: Knapsack
Java program:
import java . util . * ; class GFG { static int row = 3 ; static int col = 3 ; static int minCost ( int cost [ ] [ ] ) { for ( int i = 1 ; i < row ; i ++ ) { cost [ i ] [ 0 ] += cost [ i - 1 ] [ 0 ] ; } for ( int j = 1 ; j < col ; j ++ ) { cost [ 0 ] [ j ] += cost [ 0 ] [ j - 1 ] ; } for ( int i = 1 ; i < row ; i ++ ) { for ( int j = 1 ; j < col ; j ++ ) { cost [ i ] [ j ] += Math . min ( cost [ i - 1 ] [ j - 1 ] , Math . min ( cost [ i - 1 ] [ j ] , cost [ i ] [ j - 1 ] ) ) ; } } return cost [ row - 1 ] [ col - 1 ] ; } public static void main ( String [ ] args ) { int cost [ ] [ ] = { { 1 , 2 , 3 } , { 4 , 8 , 2 } , { 1 , 5 , 3 } } ; System . out . print ( minCost ( cost ) + "NEW_LINE"); } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
class LIS { static int max_ref ; static int _lis ( int arr [ ] , int n ) { if ( n == 1 ) return 1 ; int res , max_ending_here = 1 ; for ( int i = 1 ; i < n ; i ++ ) { res = _lis ( arr , i ) ; if ( arr [ i - 1 ] < arr [ n - 1 ] && res + 1 > max_ending_here ) max_ending_here = res + 1 ; } if ( max_ref < max_ending_here ) max_ref = max_ending_here ; return max_ending_here ; } static int lis ( int arr [ ] , int n ) { max_ref = 1 ; _lis ( arr , n ) ; return max_ref ; } public static void main ( String args [ ] ) { int arr [ ] = { 10 , 22 , 9 , 33 , 21 , 50 , 41 , 60 } ; int n = arr . length ; System . out . println ( " Length ▁ of ▁ lis ▁ is ▁ " + lis ( arr , n ) + "NEW_LINE"); } }

Accumulator variables: i
Iterator variables: i
Class/struct names: LIS
Java program:
import java . io . * ; class GFG { static int factorial ( int n ) { int res = 1 ; for ( int i = 1 ; i <= n ; ++ i ) { res *= i ; } return res ; } static int binomialCoeff ( int n , int k ) { int res = 1 ; if ( k > n - k ) k = n - k ; for ( int i = 0 ; i < k ; ++ i ) { res *= ( n - i ) ; res /= ( i + 1 ) ; } return res ; } static int catalan ( int n ) { int c = binomialCoeff ( 2 * n , n ) ; return c / ( n + 1 ) ; } static int countBST ( int n ) { int count = catalan ( n ) ; return count ; } static int countBT ( int n ) { int count = catalan ( n ) ; return count * factorial ( n ) ; } public static void main ( String [ ] args ) { int count1 , count2 , n = 5 ; count1 = countBST ( n ) ; count2 = countBT ( n ) ; System . out . println ( " Count ▁ of ▁ BST ▁ with ▁ " + n + " ▁ nodes ▁ is ▁ " + count1 ) ; System . out . println ( " Count ▁ of ▁ binary ▁ " + " trees ▁ with ▁ " + n + " ▁ nodes ▁ is ▁ " + count2 ) ; } }

Accumulator variables: res
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static void getMissingNumbers ( int arr [ ] , int N ) { for ( int i = 0 ; i < N ; i ++ ) { arr [ Math . abs ( arr [ i ] ) - 1 ] = - ( Math . abs ( arr [ Math . abs ( arr [ i ] ) - 1 ] ) ) ; } for ( int i = 0 ; i < N ; i ++ ) { if ( arr [ i ] > 0 ) System . out . print ( i + 1 + " ▁ " ) ; } } public static void main ( String [ ] args ) { int N = 5 ; int arr [ ] = { 5 , 5 , 4 , 4 , 2 } ; getMissingNumbers ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { public static boolean PosCheck ( char [ ] [ ] a , int n , int m , char check ) { for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { if ( a [ i ] [ j ] == ' * ' ) { continue ; } else { if ( ( ( ( i + j ) & 1 ) == 1 ) && a [ i ] [ j ] != check ) { return false ; } if ( ! ( ( ( i + j ) & 1 ) == 1 ) && a [ i ] [ j ] == check ) { return false ; } } } } return true ; } public static void fill ( char [ ] [ ] a , int n , int m , char odd , char even ) { for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { if ( ( ( i + j ) & 1 ) == 1 ) { a [ i ] [ j ] = odd ; } else { a [ i ] [ j ] = even ; } } } } public static void findPossibleGrid ( int n , int m , char [ ] [ ] a ) { boolean flag = true ; int k = - 1 , o = - 1 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { if ( a [ i ] [ j ] != ' * ' ) { k = i ; o = j ; break ; } } if ( k != - 1 ) { break ; } } if ( k != - 1 ) { flag = PosCheck ( a , n , m , '1' ) ; if ( flag ) { fill ( a , n , m , '1' , '0' ) ; } else { flag = PosCheck ( a , n , m , '0' ) ; if ( flag ) { fill ( a , n , m , '0' , '1' ) ; } } } else { char h = '1' ; for ( int i = 0 ; i < m ; i ++ ) { a [ 0 ] [ i ] = h ; if ( h == '1' ) { h = '0' ; } else { h = '1' ; } } for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { if ( i - 1 < 0 ) { continue ; } if ( a [ i - 1 ] [ j ] == '1' ) { a [ i ] [ j ] = '0' ; } else { a [ i ] [ j ] = '1' ; } } } flag = true ; } if ( ! flag ) { System . out . println ( " No " ) ; } else { System . out . println ( " Yes " ) ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { System . out . print ( a [ i ] [ j ] ) ; } System . out . println ( ) ; } } } public static void main ( String [ ] args ) { int n = 4 , m = 4 ; char [ ] [ ] grid = { { ' * ' , ' * ' , '1' , '0' } , { ' * ' , ' * ' , ' * ' , ' * ' } , { ' * ' , ' * ' , ' * ' , ' * ' } , { ' * ' , ' * ' , '0' , '1' } } ; findPossibleGrid ( n , m , grid ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Boolean variables: flag
Class/struct names: GFG
Java program:
import java . util . * ; import java . lang . * ; class GFG { static int oddLengthPalindrome ( int k ) { int palin = k ; k = k / 10 ; while ( k > 0 ) { int rev = k % 10 ; palin = ( palin * 10 ) + rev ; k = k / 10 ; } return palin ; } public static void main ( String [ ] args ) { int k = 504 ; System . out . println ( oddLengthPalindrome ( k ) ) ; } }

Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { static int count ( String S , int N ) { char ch [ ] = { ' u ' , ' o ' , ' i ' , ' e ' , ' a ' } ; int j = 0 ; int res = 0 ; int count = 0 ; HashSet < Character > mp = new HashSet < > ( ) ; for ( int i = 0 ; i < N ; ++ i ) { if ( S . charAt ( i ) == ch [ j ] ) { ++ count ; mp . add ( S . charAt ( i ) ) ; if ( mp . size ( ) == 5 ) { res = Math . max ( res , count ) ; } } else if ( j + 1 < 5 && S . charAt ( i ) == ch [ j + 1 ] ) { mp . add ( S . charAt ( i ) ) ; ++ count ; j ++ ; if ( mp . size ( ) == 5 ) { res = Math . max ( res , count ) ; } } else { mp . clear ( ) ; if ( S . charAt ( i ) == ' u ' ) { mp . add ( ' u ' ) ; j = 0 ; count = 1 ; } else { j = 0 ; count = 0 ; } } } return res ; } public static void main ( String [ ] args ) { String S = " ueiaoaeiouuoiea " ; int N = S . length ( ) ; System . out . println ( count ( S , N ) ) ; } }

Index/key variables: j
Accumulator variables: j
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . math . * ; import java . util . Arrays ; class GFG { static void maxSubsequenceLen ( String s , int K ) { int N = s . length ( ) ; int start = 0 , end = 0 ; char S [ ] = s . toCharArray ( ) ; Arrays . sort ( S ) ; int ans = Integer . MIN_VALUE , sum = 0 ; for ( end = 0 ; end < N ; end ++ ) { sum = sum + ( S [ end ] - ' a ' ) ; while ( sum + K < ( S [ end ] - ' a ' ) * ( end - start + 1 ) ) { sum = sum - ( S [ start ] - ' a ' ) ; start ++ ; } ans = Math . max ( ans , end - start + 1 ) ; } System . out . println ( ans ) ; } public static void main ( String args [ ] ) { String S = " acscbcca " ; int K = 1 ; maxSubsequenceLen ( S , K ) ; } }

Index/key variables: end, start
Accumulator variables: end, start
Iterator variables: end
Class/struct names: GFG
Java program:
public class GFG { static String checkPro ( int n , int k ) { double exp = 1.0 / k ; int KthRoot = ( int ) Math . pow ( n , exp ) ; int product = 1 ; for ( int i = 1 ; i < k + 1 ; i ++ ) { product = product * i ; } if ( product == n ) return " Yes " ; else { for ( int j = 2 ; j < KthRoot + 1 ; j ++ ) { product = product * ( j + k - 1 ) ; product = product / ( j - 1 ) ; if ( product == n ) return " Yes " ; } } return " No " ; } public static void main ( String [ ] args ) { int N = 210 ; int K = 3 ; System . out . println ( checkPro ( N , K ) ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . io . * ; import java . lang . * ; import java . util . * ; class GFG { static void minOperations ( String s1 , String s2 , int n ) { char a [ ] = s1 . toCharArray ( ) ; char b [ ] = s2 . toCharArray ( ) ; ArrayList < Integer > ops = new ArrayList < > ( ) ; for ( int i = n - 1 ; i >= 0 ; i -- ) { if ( a [ i ] != b [ i ] ) { if ( a [ 0 ] == b [ i ] ) { ops . add ( 1 ) ; a [ 0 ] = ( a [ 0 ] == '0' ? '1' : '0' ) ; } reverse ( a , 0 , i ) ; for ( int j = 0 ; j <= i ; j ++ ) { a [ j ] = ( a [ j ] == '0' ? '1' : '0' ) ; } ops . add ( i + 1 ) ; } } System . out . println ( ops . size ( ) ) ; for ( int x : ops ) { System . out . print ( x + " ▁ " ) ; } } static void reverse ( char a [ ] , int start , int end ) { while ( start < end ) { char temp = a [ start ] ; a [ start ] = a [ end ] ; a [ end ] = temp ; start ++ ; end -- ; } } public static void main ( String [ ] args ) { String a = "10" , b = "01" ; int N = a . length ( ) ; minOperations ( a , b , N ) ; } }

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