dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
import java . io . * ; import java . util . * ; class GFG { public static String findSubString ( String str ) { int n = str . length ( ) ; int dist_count = 0 ; HashMap < Character , Integer > mp = new HashMap < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( mp . containsKey ( str . charAt ( i ) ) ) { Integer a = mp . get ( str . charAt ( i ) ) ; mp . put ( str . charAt ( i ) , a + 1 ) ; } else { mp . put ( str . charAt ( i ) , 1 ) ; } } dist_count = mp . size ( ) ; int size = Integer . MAX_VALUE ; String res = " " ; for ( int i = 0 ; i < n ; i ++ ) { int count = 0 ; int visited [ ] = new int [ 256 ] ; for ( int j = 0 ; j < 256 ; j ++ ) visited [ j ] = 0 ; String sub_str = " " ; for ( int j = i ; j < n ; j ++ ) { if ( visited [ str . charAt ( j ) ] == 0 ) { count ++ ; visited [ str . charAt ( j ) ] = 1 ; } sub_str += str . charAt ( j ) ; if ( count == dist_count ) break ; } if ( sub_str . length ( ) < size && count == dist_count ) { res = sub_str ; size = res . length ( ) ; } } return res ; } public static void main ( String [ ] args ) { String str = " aabcbcdbca " ; System . out . println ( " Smallest ▁ window ▁ containing ▁ all ▁ distinct " + " ▁ characters ▁ is : ▁ " + findSubString ( str ) ) ; } }

Index/key variables: j
Accumulator variables: count, i, j, sub_str
Iterator variables: i, j
Class/struct names: GFG
Java program:
class Test { static void printRotatedString ( String str ) { int n = str . length ( ) ; StringBuffer sb = new StringBuffer ( str ) ; sb . append ( str ) ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j != n ; j ++ ) System . out . print ( sb . charAt ( i + j ) ) ; System . out . println ( ) ; } } public static void main ( String [ ] args ) { String str = new String ( " geeks " ) ; printRotatedString ( str ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: Test
Java program:
public class GFG { static final int M = 26 ; static int getIdx ( char ch ) { return ( ch - ' a ' ) ; } static boolean allSame ( int freq [ ] , int N ) { int same = 0 ; int i ; for ( i = 0 ; i < N ; i ++ ) { if ( freq [ i ] > 0 ) { same = freq [ i ] ; break ; } } for ( int j = i + 1 ; j < N ; j ++ ) if ( freq [ j ] > 0 && freq [ j ] != same ) return false ; return true ; } static boolean possibleSameCharFreqByOneRemoval ( String str ) { int l = str . length ( ) ; int [ ] freq = new int [ M ] ; for ( int i = 0 ; i < l ; i ++ ) freq [ getIdx ( str . charAt ( i ) ) ] ++ ; if ( allSame ( freq , M ) ) return true ; for ( char c = ' a ' ; c <= ' z ' ; c ++ ) { int i = getIdx ( c ) ; if ( freq [ i ] > 0 ) { freq [ i ] -- ; if ( allSame ( freq , M ) ) return true ; freq [ i ] ++ ; } } return false ; } public static void main ( String args [ ] ) { String str = " xyyzz " ; if ( possibleSameCharFreqByOneRemoval ( str ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } }

Index/key variables: M, i, j
Accumulator variables: c, i, j
Iterator variables: c, i, j
Class/struct names: GFG
Java program:
class IsDivisible { static boolean check ( String str ) { int n = str . length ( ) ; int oddDigSum = 0 , evenDigSum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( i % 2 == 0 ) oddDigSum += ( str . charAt ( i ) - '0' ) ; else evenDigSum += ( str . charAt ( i ) - '0' ) ; } return ( ( oddDigSum - evenDigSum ) % 11 == 0 ) ; } public static void main ( String [ ] args ) { String str = "76945" ; if ( check ( str ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } }

Accumulator variables: evenDigSum, i, oddDigSum
Iterator variables: i
Class/struct names: IsDivisible
Java program:
import java . util . ArrayList ; import java . util . Arrays ; import java . util . List ; public class Palin_pair2 { static final int ALPHABET_SIZE = 26 ; static class TrieNode { TrieNode [ ] children = new TrieNode [ ALPHABET_SIZE ] ; int id ; boolean isLeaf ; public TrieNode ( ) { isLeaf = false ; pos = new ArrayList < > ( ) ; for ( int i = 0 ; i < ALPHABET_SIZE ; i ++ ) children [ i ] = null ; } } static boolean isPalindrome ( String str , int i , int len ) { while ( i < len ) { if ( str . charAt ( i ) != str . charAt ( len ) ) return false ; i ++ ; len -- ; } return true ; } static void insert ( TrieNode root , String key , int id ) { TrieNode pCrawl = root ; for ( int level = key . length ( ) - 1 ; level >= 0 ; level -- ) { int index = key . charAt ( level ) - ' a ' ; if ( pCrawl . children [ index ] == null ) pCrawl . children [ index ] = new TrieNode ( ) ; if ( isPalindrome ( key , 0 , level ) ) ( pCrawl . pos ) . add ( id ) ; pCrawl = pCrawl . children [ index ] ; } pCrawl . id = id ; pCrawl . pos . add ( id ) ; pCrawl . isLeaf = true ; } static List < List < Integer > > result ; static void search ( TrieNode root , String key , int id ) { TrieNode pCrawl = root ; for ( int level = 0 ; level < key . length ( ) ; level ++ ) { int index = key . charAt ( level ) - ' a ' ; if ( pCrawl . id >= 0 && pCrawl . id != id && isPalindrome ( key , level , key . length ( ) - 1 ) ) { List < Integer > l = new ArrayList < > ( ) ; l . add ( id ) ; l . add ( pCrawl . id ) ; result . add ( l ) ; } if ( pCrawl . children [ index ] == null ) return ; pCrawl = pCrawl . children [ index ] ; } for ( int i : pCrawl . pos ) { if ( i == id ) continue ; List < Integer > l = new ArrayList < > ( ) ; l . add ( id ) ; l . add ( i ) ; result . add ( l ) ; } } static boolean checkPalindromePair ( List < String > vect ) { TrieNode root = new TrieNode ( ) ; for ( int i = 0 ; i < vect . size ( ) ; i ++ ) insert ( root , vect . get ( i ) , i ) ; result = new ArrayList < > ( ) ; for ( int i = 0 ; i < vect . size ( ) ; i ++ ) { search ( root , vect . get ( i ) , i ) ; if ( result . size ( ) > 0 ) return true ; } return false ; } public static void main ( String args [ ] ) { List < String > vect = Arrays . asList ( " geekf " , " geeks " , " or " , " keeg " , " abc " , " bc " ) ; if ( checkPalindromePair ( vect ) == true ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } }

Index/key variables: ALPHABET_SIZE, i, index
Accumulator variables: i, len, level
Iterator variables: i, level
Boolean variables: isLeaf
Class/struct names: Palin_pair2, TrieNode
Java program:
class GFG { static int hammingDist ( String str1 , String str2 ) { int i = 0 , count = 0 ; while ( i < str1 . length ( ) ) { if ( str1 . charAt ( i ) != str2 . charAt ( i ) ) count ++ ; i ++ ; } return count ; } public static void main ( String [ ] args ) { String str1 = " geekspractice " ; String str2 = " nerdspractise " ; System . out . println ( hammingDist ( str1 , str2 ) ) ; } }

Accumulator variables: count, i
Class/struct names: GFG
Java program:
public class GFG { static final int MAX_CHAR = 26 ; static boolean arekAnagrams ( String str1 , String str2 , int k ) { int n = str1 . length ( ) ; if ( str2 . length ( ) != n ) return false ; int [ ] count1 = new int [ MAX_CHAR ] ; int [ ] count2 = new int [ MAX_CHAR ] ; int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) count1 [ str1 . charAt ( i ) - ' a ' ] ++ ; for ( int i = 0 ; i < n ; i ++ ) count2 [ str2 . charAt ( i ) - ' a ' ] ++ ; for ( int i = 0 ; i < MAX_CHAR ; i ++ ) if ( count1 [ i ] > count2 [ i ] ) count = count + Math . abs ( count1 [ i ] - count2 [ i ] ) ; return ( count <= k ) ; } public static void main ( String args [ ] ) { String str1 = " anagram " ; String str2 = " grammar " ; int k = 2 ; if ( arekAnagrams ( str1 , str2 , k ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } }

Index/key variables: MAX_CHAR, i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int removeSpaces ( char [ ] str ) { int count = 0 ; for ( int i = 0 ; i < str . length ; i ++ ) if ( str [ i ] != ' ▁ ' ) return count ; } public static void main ( String [ ] args ) { char str [ ] = " g ▁ eeks ▁ for ▁ ge ▁ eeks ▁ " . toCharArray ( ) ; int i = removeSpaces ( str ) ; System . out . println ( String . valueOf ( str ) . subSequence ( 0 , i ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class CountSubString { int countSubStr ( char str [ ] , int n ) { for ( int i = 0 ; i < n ; i ++ ) { if ( str [ i ] == '1' ) m ++ ; } return m * ( m - 1 ) / 2 ; } public static void main ( String [ ] args ) { CountSubString count = new CountSubString ( ) ; String string = "00100101" ; char str [ ] = string . toCharArray ( ) ; int n = str . length ; System . out . println ( count . countSubStr ( str , n ) ) ; } }

Index/key variables: i
Accumulator variables: i, m
Iterator variables: i
Class/struct names: CountSubString
Java program:
import java . io . * ; class GFG { static int count9s ( String number ) { int count = 0 ; int n = number . length ( ) ; for ( int i = 0 ; i < n ; i ++ ) { int sum = number . charAt ( i ) - '0' ; if ( number . charAt ( i ) == '9' ) count ++ ; for ( int j = i + 1 ; j < n ; j ++ ) { sum = ( sum + number . charAt ( j ) - '0' ) % 9 ; if ( sum == 0 ) count ++ ; } } return count ; } public static void main ( String [ ] args ) { System . out . println ( count9s ( "4189" ) ) ; System . out . println ( count9s ( "1809" ) ) ; } }

Accumulator variables: count, i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GfG { static void generateGrayarr ( int n ) { if ( n <= 0 ) return ; ArrayList < String > arr = new ArrayList < String > ( ) ; arr . add ( "0" ) ; arr . add ( "1" ) ; int i , j ; for ( i = 2 ; i < ( 1 << n ) ; i = i << 1 ) { for ( j = i - 1 ; j >= 0 ; j -- ) arr . add ( arr . get ( j ) ) ; for ( j = 0 ; j < i ; j ++ ) arr . set ( j , "0" + arr . get ( j ) ) ; for ( j = i ; j < 2 * i ; j ++ ) arr . set ( j , "1" + arr . get ( j ) ) ; } for ( i = 0 ; i < arr . size ( ) ; i ++ ) System . out . println ( arr . get ( i ) ) ; } public static void main ( String [ ] args ) { generateGrayarr ( 3 ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GfG
Java program:
import java . util . * ; class GFG { static void divide ( String str , int n ) { if ( str . length ( ) % n != 0 ) { System . out . print ( " Invalid ▁ Input : ▁ String ▁ size " ) ; System . out . print ( " ▁ is ▁ not ▁ divisible ▁ by ▁ n " ) ; return ; } int parts = str . length ( ) / n ; int start = 0 ; int t = parts ; while ( start < str . length ( ) ) { String temp = new String ( str ) ; System . out . print ( temp . substring ( start , parts ) + "NEW_LINE"); start = parts ; parts += t ; } } public static void main ( String [ ] args ) { String str = " a _ simple _ divide _ String _ quest " ; divide ( str , 4 ) ; } }

Accumulator variables: parts
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class Sol { int [ ] [ ] countMap ; int cnt = Integer . MAX_VALUE ; public int minStickers ( String [ ] stickers , String target ) { if ( target == null ) return - 1 ; if ( target . length ( ) == 0 ) return 0 ; if ( stickers == null stickers . length == 0 ) return - 1 ; int m = stickers . length ; countMap = new int [ m ] [ 26 ] ; for ( int i = 0 ; i < stickers . length ; i ++ ) { String s = stickers [ i ] ; for ( char c : s . toCharArray ( ) ) { countMap [ i ] ++ ; } } count ( 0 , 0 , new int [ 26 ] , target , stickers ) ; return cnt == Integer . MAX_VALUE ? - 1 : cnt ; } private void count ( int curCnt , int pos , int [ ] charAvailable , String target , String [ ] stickers ) { if ( curCnt >= cnt ) return ; int m = stickers . length ; int n = target . length ( ) ; if ( pos == n ) { cnt = Math . min ( cnt , curCnt ) ; return ; } char c = target . charAt ( pos ) ; if ( charAvailable > 0 ) { charAvailable -- ; count ( curCnt , pos + 1 , charAvailable , target , stickers ) ; charAvailable ++ ; } else { for ( int i = 0 ; i < m ; i ++ ) { if ( countMap [ i ] == 0 ) continue ; for ( int j = 0 ; j < 26 ; j ++ ) { charAvailable [ j ] += countMap [ i ] [ j ] ; } count ( curCnt + 1 , pos , charAvailable , target , stickers ) ; for ( int j = 0 ; j < 26 ; j ++ ) { charAvailable [ j ] -= countMap [ i ] [ j ] ; } } } } } class GFG { public static void main ( String [ ] args ) { Sol st = new Sol ( ) ; String [ ] str = { " with " , " example " , " science " } ; String target = " thehat " ; int Result = st . minStickers ( str , target ) ; System . out . println ( Result ) ; } }

Index/key variables: i, j, m
Accumulator variables: charAvailable, i, j
Iterator variables: c, i, j
Class/struct names: GFG, Sol
Java program:
import java . util . * ; class GFG { static Vector < String > possiblePaths = new Vector < > ( ) ; static String path = " " ; static final int MAX = 5 ; static boolean isSafe ( int row , int col , int m [ ] [ ] , int n , boolean visited [ ] [ ] ) { if ( row == - 1 row == n col == - 1 col == n visited [ row ] [ col ] m [ row ] [ col ] == 0 ) return false ; return true ; } static void printPathUtil ( int row , int col , int m [ ] [ ] , int n , boolean visited [ ] [ ] ) { if ( row == - 1 row == n col == - 1 col == n visited [ row ] [ col ] m [ row ] [ col ] == 0 ) return ; if ( row == n - 1 && col == n - 1 ) { possiblePaths . add ( path ) ; return ; } visited [ row ] [ col ] = true ; if ( isSafe ( row + 1 , col , m , n , visited ) ) { path += ' D ' ; printPathUtil ( row + 1 , col , m , n , visited ) ; path = path . substring ( 0 , path . length ( ) - 1 ) ; } if ( isSafe ( row , col - 1 , m , n , visited ) ) { path += ' L ' ; printPathUtil ( row , col - 1 , m , n , visited ) ; path = path . substring ( 0 , path . length ( ) - 1 ) ; } if ( isSafe ( row , col + 1 , m , n , visited ) ) { path += ' R ' ; printPathUtil ( row , col + 1 , m , n , visited ) ; path = path . substring ( 0 , path . length ( ) - 1 ) ; } if ( isSafe ( row - 1 , col , m , n , visited ) ) { path += ' U ' ; printPathUtil ( row - 1 , col , m , n , visited ) ; path = path . substring ( 0 , path . length ( ) - 1 ) ; } visited [ row ] [ col ] = false ; } static void printPath ( int m [ ] [ ] , int n ) { boolean [ ] [ ] visited = new boolean [ n ] [ MAX ] ; printPathUtil ( 0 , 0 , m , n , visited ) ; for ( int i = 0 ; i < possiblePaths . size ( ) ; i ++ ) System . out . print ( possiblePaths . get ( i ) + " ▁ " ) ; } public static void main ( String [ ] args ) { int m [ ] [ ] = { { 1 , 0 , 0 , 0 , 0 } , { 1 , 1 , 1 , 1 , 1 } , { 1 , 1 , 1 , 0 , 1 } , { 0 , 0 , 0 , 0 , 1 } , { 0 , 0 , 0 , 0 , 1 } } ; int n = m . length ; printPath ( m , n ) ; } }

Index/key variables: MAX, col, n, row
Accumulator variables: i, path
Iterator variables: i
Class/struct names: GFG
Java program:
class GfG { static void breakLine ( ) { System . out . print ( " -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - "); } static int MAX = 10 ; static int arr [ ] = new int [ MAX ] , no ; static void nQueens ( int k , int n ) { for ( int i = 1 ; i <= n ; i ++ ) { if ( canPlace ( k , i ) ) { arr [ k ] = i ; if ( k == n ) { display ( n ) ; } else { nQueens ( k + 1 , n ) ; } } } } static boolean canPlace ( int k , int i ) { for ( int j = 1 ; j <= k - 1 ; j ++ ) { if ( arr [ j ] == i || ( Math . abs ( arr [ j ] - i ) == Math . abs ( j - k ) ) ) { return false ; } } return true ; } static void display ( int n ) { breakLine ( ) ; System . out . print ( " Arrangement ▁ No . ▁ " + ++ no ) ; breakLine ( ) ; for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = 1 ; j <= n ; j ++ ) { if ( arr [ i ] != j ) { System . out . print ( " TABSYMBOL _ " ) ; } else { System . out . print ( " TABSYMBOL Q " ) ; } } System . out . println ( " " ) ; } breakLine ( ) ; } public static void main ( String [ ] args ) { int n = 4 ; nQueens ( 1 , n ) ; } }

Index/key variables: MAX, i, j, k
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GfG
Java program:
import java . io . * ; class GFG { static int R = 3 ; static int C = 10 ; static class Pair { boolean found ; int val ; Pair ( boolean x , int y ) { found = x ; val = y ; } } static Pair findLongestPathUtil ( int mat [ ] [ ] , int i , int j , int x , int y , boolean visited [ ] [ ] ) { if ( i == x && j == y ) return new Pair ( true , 0 ) ; if ( i < 0 i >= R j < 0 j >= C mat [ i ] [ j ] == 0 visited [ i ] [ j ] ) return new Pair ( false , Integer . MAX_VALUE ) ; visited [ i ] [ j ] = true ; int res = Integer . MIN_VALUE ; Pair sol = findLongestPathUtil ( mat , i , j - 1 , x , y , visited ) ; if ( sol . found ) res = Math . max ( sol . val , res ) ; sol = findLongestPathUtil ( mat , i , j + 1 , x , y , visited ) ; if ( sol . found ) res = Math . max ( sol . val , res ) ; sol = findLongestPathUtil ( mat , i - 1 , j , x , y , visited ) ; if ( sol . found ) res = Math . max ( sol . val , res ) ; sol = findLongestPathUtil ( mat , i + 1 , j , x , y , visited ) ; if ( sol . found ) res = Math . max ( sol . val , res ) ; visited [ i ] [ j ] = false ; if ( res != Integer . MIN_VALUE ) return new Pair ( true , res + 1 ) ; else return new Pair ( false , Integer . MAX_VALUE ) ; } static void findLongestPath ( int mat [ ] [ ] , int i , int j , int x , int y ) { boolean visited [ ] [ ] = new boolean [ R ] [ C ] ; Pair p = findLongestPathUtil ( mat , i , j , x , y , visited ) ; if ( p . found ) System . out . println ( " Length ▁ of ▁ longest ▁ possible ▁ route ▁ is ▁ " + p . val ) ; else System . out . println ( " Destination ▁ not ▁ reachable ▁ from ▁ given ▁ source " ) ; } public static void main ( String [ ] args ) { int mat [ ] [ ] = { { 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 } , { 1 , 1 , 0 , 1 , 1 , 0 , 1 , 1 , 0 , 1 } , { 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 } } ; findLongestPath ( mat , 0 , 0 , 1 , 7 ) ; } }

Index/key variables: C, R, i, j
Class/struct names: GFG, Pair
Java program:
import java . util . HashSet ; class CP { public static void main ( String [ ] args ) { int [ ] A = { 11 , 15 , 7 , 19 } ; int N = A . length ; HashSet < Integer > set = new HashSet < > ( ) ; int i , j , res ; for ( i = 0 ; i < N ; ++ i ) for ( j = i , res = Integer . MAX_VALUE ; j < N ; ++ j ) { res &= A [ j ] ; set . add ( res ) ; } System . out . println ( set ) ; } }

Index/key variables: j
Accumulator variables: res
Iterator variables: i, j
Class/struct names: CP
Java program:
import java . util . * ; import java . io . * ; public class RangeQueries { static class Query { long L ; long R ; } public static int upperBound ( ArrayList < Long > validNumbers , Long value ) { int low = 0 ; int high = validNumbers . size ( ) - 1 ; while ( low < high ) { int mid = ( low + high ) / 2 ; if ( value >= validNumbers . get ( mid ) ) { low = mid + 1 ; } else { high = mid ; } } return low ; } public static void answerQueries ( ArrayList < Query > queries ) { Set < Long > allNum = new HashSet < > ( ) ; allNum . add ( 0L ) ; for ( int i = 0 ; i <= 60 ; i ++ ) { for ( int j = 0 ; j <= 60 ; j ++ ) { for ( int k = 0 ; k <= 60 ; k ++ ) { if ( i == j && j == k ) { allNum . add ( 1L << i ) ; } else if ( i == j && j != k ) { long toAdd = ( 1L << i ) + ( 1L << k ) ; allNum . add ( toAdd ) ; } else if ( i == k && k != j ) { long toAdd = ( 1L << i ) + ( 1L << j ) ; allNum . add ( toAdd ) ; } else if ( j == k && k != i ) { long toAdd = ( 1L << j ) + ( 1L << i ) ; allNum . add ( toAdd ) ; } else { long toAdd = ( 1L << i ) + ( 1L << j ) + ( 1L << k ) ; allNum . add ( toAdd ) ; } } } } ArrayList < Long > validNumbers = new ArrayList < > ( ) ; for ( Long num : allNum ) { validNumbers . add ( num ) ; } Collections . sort ( validNumbers ) ; for ( int i = 0 ; i < queries . size ( ) ; i ++ ) { long L = queries . get ( i ) . L ; long R = queries . get ( i ) . R ; if ( R < L ) { long temp = L ; L = R ; R = temp ; } if ( L == 0 ) { int indxOfLastNum = upperBound ( validNumbers , R ) ; System . out . println ( indxOfLastNum + 1 ) ; } else { int indxOfFirstNum = upperBound ( validNumbers , L ) ; int indxOfLastNum = upperBound ( validNumbers , R ) ; System . out . println ( ( indxOfLastNum - indxOfFirstNum + 1 ) ) ; } } } public static void main ( String [ ] args ) { int Q = 2 ; ArrayList < Query > queries = new ArrayList < > ( ) ; Query q1 = new Query ( ) ; q1 . L = 3 ; q1 . R = 7 ; Query q2 = new Query ( ) ; q2 . L = 10 ; q2 . R = 16 ; queries . add ( q1 ) ; queries . add ( q2 ) ; answerQueries ( queries ) ; } }

Accumulator variables: i, j, k
Iterator variables: i, j, k, num
Class/struct names: Query, RangeQueries
Java program:
import java . util . * ; class GFG { public static int minStepsRecur ( int height [ ] , int l , int r , int h ) { if ( l >= r ) return 0 ; int m = l ; for ( int i = l ; i < r ; i ++ ) if ( height [ i ] < height [ m ] ) m = i ; return Math . min ( r - l , minStepsRecur ( height , l , m , height [ m ] ) + minStepsRecur ( height , m + 1 , r , height [ m ] ) + height [ m ] - h ) ; } public static int minSteps ( int height [ ] , int N ) { return minStepsRecur ( height , 0 , N , 0 ) ; } public static void main ( String [ ] args ) { int height [ ] = { 2 , 1 , 2 , 5 , 1 } ; int N = height . length ; System . out . println ( minSteps ( height , N ) ) ; } }

Index/key variables: i, m
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int countDirectPath ( int N ) { return N + ( N * ( N - 3 ) ) / 2 ; } public static void main ( String [ ] args ) { int N = 5 ; System . out . print ( countDirectPath ( N ) ) ; } }

Class/struct names: GFG
Java program:
import java . util . ArrayList ; class GFG { static class pair < T , V > { T fi ; V se ; pair ( T a , V b ) { this . fi = a ; this . se = b ; } } static void findPoint ( int n , ArrayList < pair < Integer , Integer > > p ) { for ( int i = 0 ; i < n * 4 + 1 ; ++ i ) { int x1 = ( int ) 2e9 , x2 = ( int ) - 2e9 ; int y1 = ( int ) 2e9 , y2 = ( int ) - 2e9 ; for ( int j = 0 ; j < n * 4 + 1 ; ++ j ) if ( i != j ) { x1 = Math . min ( x1 , p . get ( j ) . fi ) ; x2 = Math . max ( x2 , p . get ( j ) . fi ) ; y1 = Math . min ( y1 , p . get ( j ) . se ) ; y2 = Math . max ( y2 , p . get ( j ) . se ) ; } boolean ok = true ; int c1 = 0 , c2 = 0 ; int c3 = 0 , c4 = 0 ; for ( int j = 1 ; j < n * 4 + 1 ; ++ j ) if ( i != j ) { if ( ( p . get ( j ) . fi == x1 || p . get ( j ) . fi == x2 ) || ( ( p . get ( j ) . se == y1 || p . get ( j ) . se == y2 ) ) ) { if ( p . get ( j ) . fi == x1 ) ++ c1 ; if ( p . get ( j ) . fi == x2 ) ++ c2 ; if ( p . get ( j ) . se == y1 ) ++ c3 ; if ( p . get ( j ) . se == y2 ) ++ c4 ; } else ok = false ; } if ( ok && c1 >= n && c2 >= n && c3 >= n && c4 >= n && x2 - x1 == y2 - y1 ) { System . out . println ( p . get ( i ) . fi + " ▁ " + p . get ( i ) . se ) ; } } } public static void main ( String [ ] args ) { int N = 2 ; ArrayList < pair < Integer , Integer > > arr = new ArrayList < > ( ) ; arr . add ( new pair < Integer , Integer > ( 0 , 0 ) ) ; arr . add ( new pair < Integer , Integer > ( 0 , 1 ) ) ; arr . add ( new pair < Integer , Integer > ( 0 , 2 ) ) ; arr . add ( new pair < Integer , Integer > ( 1 , 0 ) ) ; arr . add ( new pair < Integer , Integer > ( 1 , 1 ) ) ; arr . add ( new pair < Integer , Integer > ( 1 , 2 ) ) ; arr . add ( new pair < Integer , Integer > ( 2 , 0 ) ) ; arr . add ( new pair < Integer , Integer > ( 2 , 1 ) ) ; arr . add ( new pair < Integer , Integer > ( 2 , 2 ) ) ; findPoint ( N , arr ) ; } }

Iterator variables: i, j
Boolean variables: ok
Class/struct names: GFG, pair
Java program:
import java . io . * ; import java . util . * ; class GFG { static int triacontagonalNum ( int n ) { return ( 28 * n * n - 26 * n ) / 2 ; } public static void main ( String [ ] args ) { int n = 3 ; System . out . println ( "3rd ▁ triacontagonal ▁ Number ▁ is ▁ = ▁ " + triacontagonalNum ( n ) ) ; } }

Class/struct names: GFG
Java program:
class GFG { public static int hexacontagonNum ( int n ) { return ( 58 * n * n - 56 * n ) / 2 ; } public static void main ( String [ ] args ) { int n = 3 ; System . out . println ( "3rd ▁ hexacontagon ▁ Number ▁ is ▁ = ▁ " + hexacontagonNum ( n ) ) ; } }

Class/struct names: GFG
Java program:
class GFG { public static int enneacontagonNum ( int n ) { return ( 88 * n * n - 86 * n ) / 2 ; } public static void main ( String [ ] args ) { int n = 3 ; System . out . println ( "3rd ▁ enneacontagon ▁ Number ▁ is ▁ = ▁ " + enneacontagonNum ( n ) ) ; } }

Class/struct names: GFG