dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
import java . util . * ; class GFG { static int calc ( int a , int b ) { return a * b + ( b - a ) ; } static int findMaximum ( int [ ] arr , int N ) { Arrays . sort ( arr ) ; int ans = ( int ) - 1e9 ; ans = Math . max ( ans , calc ( arr [ 0 ] , arr [ 1 ] ) ) ; ans = Math . max ( ans , calc ( arr [ N - 2 ] , arr [ N - 1 ] ) ) ; return ans ; } public static void main ( String [ ] args ) { int [ ] arr = { 0 , - 47 , 12 } ; int N = arr . length ; System . out . println ( findMaximum ( arr , N ) ) ; } }

Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { static int minKBitFlips ( int [ ] A , int K ) { Queue < Integer > flip = new LinkedList < > ( ) ; int count = 0 ; for ( int i = 0 ; i < A . length ; i ++ ) { if ( ! flip . isEmpty ( ) && ( i - flip . peek ( ) >= K ) ) { flip . poll ( ) ; } if ( A [ i ] % 2 == flip . size ( ) % 2 ) { if ( i + K - 1 >= A . length ) { return - 1 ; } count ++ ; } } return count ; } public static void main ( String [ ] args ) { int [ ] A = { 0 , 1 , 0 } ; int K = 1 ; int ans = minKBitFlips ( A , K ) ; System . out . println ( ans ) ; } }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { static int minKBitFlips ( int [ ] A , int K ) { int [ ] temp = new int [ A . length ] ; int count = 0 ; int flip = 0 ; for ( int i = 0 ; i < A . length ; ++ i ) { flip ^= temp [ i ] ; if ( A [ i ] == flip ) { count ++ ; if ( i + K > A . length ) { return - 1 ; } flip ^= 1 ; if ( i + K < A . length ) { temp [ i + K ] ^= 1 ; } } } return count ; } public static void main ( String [ ] args ) { int [ ] A = { 0 , 1 , 0 } ; int K = 1 ; int ans = minKBitFlips ( A , K ) ; System . out . println ( ans ) ; } }

Index/key variables: i
Accumulator variables: count, flip
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . lang . * ; import java . util . * ; class GFG { static void findKthElement ( int N , int K ) { ArrayList < Integer > v = new ArrayList < > ( ) ; for ( int i = 1 ; i <= N ; i ++ ) { if ( i % 2 == 0 ) { v . add ( i ) ; } } for ( int i = 1 ; i <= N ; i ++ ) { if ( i % 2 != 0 ) { v . add ( i ) ; } } System . out . println ( v . get ( K - 1 ) ) ; } public static void main ( String [ ] args ) { int N = 10 , K = 3 ; findKthElement ( N , K ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int minimize ( int n ) { int optEle = n ; String strEle = Integer . toString ( n ) ; for ( int idx = 0 ; idx < strEle . length ( ) ; idx ++ ) { int temp = Integer . parseInt ( strEle . substring ( idx ) + strEle . substring ( 0 , idx ) ) ; optEle = Math . min ( optEle , temp ) ; } return optEle ; } static int maximize ( int n ) { int optEle = n ; String strEle = Integer . toString ( n ) ; for ( int idx = 0 ; idx < strEle . length ( ) ; idx ++ ) { int temp = Integer . parseInt ( strEle . substring ( idx ) + strEle . substring ( 0 , idx ) ) ; optEle = Math . max ( optEle , temp ) ; } return optEle ; } static void minimumDifference ( int [ ] arr ) { int caseOne = 0 ; int minVal = 0 ; int maxVal = 0 ; for ( int i = 0 ; i < arr . length ; i ++ ) { if ( i % 2 == 0 ) minVal += minimize ( arr [ i ] ) ; else maxVal += maximize ( arr [ i ] ) ; } caseOne = Math . abs ( maxVal - minVal ) ; int caseTwo = 0 ; minVal = 0 ; maxVal = 0 ; for ( int i = 0 ; i < arr . length ; i ++ ) { if ( i % 2 == 0 ) maxVal += maximize ( arr [ i ] ) ; else minVal += minimize ( arr [ i ] ) ; caseTwo = Math . abs ( maxVal - minVal ) ; } System . out . println ( Math . max ( caseOne , caseTwo ) ) ; } public static void main ( String [ ] args ) { int [ ] arr = { 332 , 421 , 215 , 584 , 232 } ; minimumDifference ( arr ) ; } }

Index/key variables: i
Accumulator variables: i, idx, maxVal, minVal
Iterator variables: i, idx
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int minimumStepReqArr ( int [ ] arr , int N ) { int cntStep = 0 ; N += 1 ; for ( int i = 31 ; i >= 0 ; i -- ) { if ( ( N & ( 1 << i ) ) != 0 ) { cntStep += 1 ; } } return cntStep ; } public static void main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 3 } ; int N = arr . length ; System . out . println ( minimumStepReqArr ( arr , N ) ) ; } }

Accumulator variables: N, cntStep, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { public static void minOpsToEmptyString ( String S , int N ) { int one = 0 , zero = 0 ; int x0 = 0 , x1 = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( S . charAt ( i ) == '0' ) { x0 ++ ; x1 = 0 ; } else { x1 ++ ; x0 = 0 ; } zero = Math . max ( x0 , zero ) ; one = Math . max ( x1 , one ) ; } System . out . println ( Math . max ( one , zero ) ) ; } public static void main ( String [ ] args ) { String S = "0100100111" ; int N = S . length ( ) ; minOpsToEmptyString ( S , N ) ; } }

Accumulator variables: i, x0, x1
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static void ReverseSwap ( int [ ] [ ] mat , int n ) { int [ ] lowerEle = new int [ n ] ; int [ ] upperEle = new int [ n ] ; int index ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { index = Math . abs ( i - j ) ; if ( i == j ) { continue ; } else if ( j < i ) { lowerEle [ index ] = mat [ i ] [ j ] ; } else { upperEle [ index ] = mat [ i ] [ j ] ; } } } for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { index = Math . abs ( i - j ) ; if ( i == j ) { continue ; } else if ( j < i ) { mat [ i ] [ j ] = upperEle [ index ] ; } else { mat [ i ] [ j ] = lowerEle [ index -- ] ; } } } for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { System . out . print ( mat [ i ] [ j ] + " ▁ " ) ; } System . out . println ( ) ; } } public static void main ( String [ ] args ) { int [ ] [ ] mat = new int [ ] [ ] { { 1 , 2 } , { 4 , 5 } } ; int N = mat . length ; ReverseSwap ( mat , N ) ; } }

Index/key variables: i, index, j, n
Accumulator variables: i, index, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static Vector < Integer > primePower ( int X ) { Vector < Integer > primePow = new Vector < Integer > ( ) ; for ( int i = 2 ; i * i <= X ; i ++ ) { if ( X % i == 0 ) { int p = 1 ; while ( X % i == 0 ) { X /= i ; p *= i ; } primePow . add ( p ) ; } } if ( X > 1 ) { primePow . add ( X ) ; } return primePow ; } static int getSum ( int [ ] ar ) { int sum = 0 ; for ( int i : ar ) { sum += i ; } return sum ; } static int getMinSum ( int pos , int [ ] arr , Vector < Integer > primePow ) { if ( pos == primePow . size ( ) ) { return getSum ( arr ) ; } int res = Integer . MAX_VALUE ; for ( int i = 0 ; i < arr . length ; i ++ ) { arr [ i ] *= primePow . get ( pos ) ; res = Math . min ( res , getMinSum ( pos + 1 , arr , primePow ) ) ; arr [ i ] /= primePow . get ( pos ) ; } return res ; } static int minimumSumWithGivenLCM ( int k , int x ) { Vector < Integer > primePow = primePower ( x ) ; int n = primePow . size ( ) ; int sum = 0 ; if ( n <= k ) { for ( int i : primePow ) { sum += i ; } sum += k - n ; } else { int [ ] arr = new int [ k ] ; Arrays . fill ( arr , 1 ) ; sum = getMinSum ( 0 , arr , primePow ) ; } return sum ; } public static void main ( String [ ] args ) { int k = 3 , x = 210 ; System . out . print ( minimumSumWithGivenLCM ( k , x ) ) ; } }

Index/key variables: i, k
Accumulator variables: X, i, p, sum
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; import java . lang . * ; class GFG { static int findMinOperationsReqEmpStr ( String str ) { int cntOne = 0 ; int cntZero = 0 ; int N = str . length ( ) ; for ( int i = 0 ; i < N ; i ++ ) { if ( str . charAt ( i ) == '0' ) { if ( cntOne != 0 ) { cntOne -- ; } cntZero ++ ; } else { if ( cntZero != 0 ) { cntZero -- ; } cntOne ++ ; } } return ( cntOne + cntZero ) ; } public static void main ( String [ ] args ) { String str = "0100100111" ; System . out . print ( findMinOperationsReqEmpStr ( str ) ) ; } }

Accumulator variables: cntOne, cntZero, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { public static int countChanges ( char mat [ ] [ ] ) { int n = mat . length ; int m = mat [ 0 ] . length ; int ans = 0 ; for ( int j = 0 ; j < m - 1 ; j ++ ) { if ( mat [ n - 1 ] [ j ] != ' R ' ) ans ++ ; } for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( mat [ i ] [ m - 1 ] != ' D ' ) ans ++ ; } return ans ; } public static void main ( String [ ] args ) { char arr [ ] [ ] = { { ' R ' , ' R ' , ' R ' , ' D ' } , { ' D ' , ' D ' , ' D ' , ' R ' } , { ' R ' , ' D ' , ' R ' , ' F ' } } ; int cnt = countChanges ( arr ) ; System . out . println ( cnt ) ; } }

Index/key variables: i, j
Accumulator variables: ans, i, j
Iterator variables: i, j
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 = null ; temp . right = null ; return temp ; } static int isSorted ( Node root ) { int prevMax = Integer . MIN_VALUE ; int minval ; int maxval ; int levelSize ; Queue < Node > q = new LinkedList < Node > ( ) ; q . add ( root ) ; while ( ! q . isEmpty ( ) ) { levelSize = q . size ( ) ; minval = Integer . MAX_VALUE ; maxval = Integer . MIN_VALUE ; while ( levelSize > 0 ) { root = q . peek ( ) ; q . remove ( ) ; levelSize -- ; minval = Math . min ( minval , root . key ) ; maxval = Math . max ( maxval , root . key ) ; if ( root . left != null ) q . add ( root . left ) ; if ( root . right != null ) q . add ( root . right ) ; } if ( minval <= prevMax ) return 0 ; prevMax = maxval ; } return 1 ; } public static void main ( String [ ] args ) { Node root = newNode ( 1 ) ; root . left = newNode ( 4 ) ; root . left . right = newNode ( 6 ) ; root . left . right . left = newNode ( 8 ) ; root . left . right . right = newNode ( 9 ) ; root . left . right . left . left = newNode ( 12 ) ; root . left . right . right . right = newNode ( 10 ) ; if ( isSorted ( root ) == 1 ) System . out . println ( " Sorted " ) ; else System . out . println ( " Not ▁ sorted " ) ; } }

Accumulator variables: levelSize
Class/struct names: GfG, Node
Java program:
import java . io . * ; class GFG { static int gcd ( int a , int b ) { if ( b == 0 ) return a ; return gcd ( b , a % b ) ; } static void printSmallSub ( int [ ] arr , int N ) { int gcdArr = 0 ; for ( int i = 0 ; i < N ; i ++ ) { gcdArr = gcd ( gcdArr , arr [ i ] ) ; } for ( int i = 0 ; i < N ; i ++ ) { if ( arr [ i ] == gcdArr ) { System . out . print ( arr [ i ] + " ▁ " ) ; return ; } } for ( int i = 0 ; i < N ; i ++ ) { for ( int j = i + 1 ; j < N ; j ++ ) { if ( gcd ( arr [ i ] , arr [ j ] ) == gcdArr ) { System . out . print ( arr [ i ] + " ▁ " + arr [ j ] ) ; return ; } } } } public static void main ( String [ ] args ) { int arr [ ] = { 4 , 6 , 12 } ; int N = arr . length ; printSmallSub ( arr , N ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { public static int X = 1000000 ; public static boolean [ ] getPrimeNum ( ) { boolean isPrime [ ] = new boolean [ X ] ; Arrays . fill ( isPrime , true ) ; isPrime [ 0 ] = false ; isPrime [ 1 ] = false ; for ( int i = 2 ; i * i <= X ; i ++ ) { if ( isPrime [ i ] == true ) { for ( int j = i * i ; j < X ; j += i ) { isPrime [ j ] = false ; } } } return isPrime ; } public static int cntPairs ( int arr [ ] , int N ) { boolean isPrime [ ] = getPrimeNum ( ) ; int cntOne = 0 ; int cntPrime = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( arr [ i ] == 1 ) { cntOne += 1 ; } else if ( isPrime [ i ] ) { cntPrime += 1 ; } } int cntNonComp = 0 ; cntNonComp = cntPrime * cntOne + cntOne * ( cntOne - 1 ) / 2 ; int res = 0 ; res = N * ( N - 1 ) / 2 - cntNonComp ; return res ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 1 , 2 , 2 , 8 } ; int N = arr . length ; System . out . println ( cntPairs ( arr , N ) ) ; } }

Index/key variables: X, i, j
Accumulator variables: cntOne, cntPrime, i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int power ( int X , int n ) { int res = 1 ; while ( n != 0 ) { if ( ( n & 1 ) != 0 ) res = res * X ; X = X * X ; n = n >> 1 ; } return res ; } static int closestgtNum ( int N ) { int n = ( int ) Math . log10 ( N ) + 1 ; int P = power ( 10 , n - 1 ) ; int Y = N % P ; int res = N + ( P - Y ) ; return res ; } public static void main ( String [ ] args ) { int N = 120 ; System . out . print ( closestgtNum ( N ) ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; import java . lang . * ; class GFG { static void RearrangeB ( int [ ] A , int [ ] B ) { int n = A . length ; if ( n == 1 && A [ 0 ] == B [ 0 ] ) { System . out . println ( " - 1" ) ; return ; } for ( int i = 0 ; i < n / 2 ; i ++ ) { int t = B [ i ] ; B [ i ] = B [ n - i - 1 ] ; B [ n - i - 1 ] = t ; } for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( B [ i ] == A [ i ] ) { int t = B [ i + 1 ] ; B [ i + 1 ] = B [ i ] ; B [ i ] = t ; break ; } } for ( int k : B ) System . out . print ( k + " ▁ " ) ; } public static void main ( String [ ] args ) { int [ ] A = { 2 , 4 , 5 , 8 } ; int [ ] B = { 2 , 4 , 5 , 8 } ; RearrangeB ( A , B ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i, k
Class/struct names: GFG
Java program:
public class Main { static void swap ( int N , int M , int mat [ ] [ ] , int startx_X , int starty_X , int startx_Y , int starty_Y ) { int row = 0 ; int col = 0 ; for ( int i = startx_X ; ; i ++ ) { col = 0 ; for ( int j = startx_X ; ; j ++ ) { int temp = mat [ i ] [ j ] ; mat [ i ] [ j ] = mat [ startx_Y + row ] [ starty_Y + col ] ; mat [ startx_Y + row ] [ starty_Y + col ] = temp ; col ++ ; if ( col >= M / 2 ) break ; } row ++ ; if ( row >= N / 2 ) break ; } } static void swapQuadOfMatrix ( int N , int M , int mat [ ] [ ] , int X , int Y ) { if ( X == 1 && Y == 2 ) { swap ( N , M , mat , 0 , 0 , 0 , M / 2 ) ; } else if ( X == 1 && Y == 3 ) { swap ( N , M , mat , 0 , 0 , N / 2 , 0 ) ; } else if ( X == 1 && Y == 4 ) { swap ( N , M , mat , 0 , 0 , N / 2 , M / 2 ) ; } else if ( X == 2 && Y == 3 ) { swap ( N , M , mat , 0 , M / 2 , N / 2 , 0 ) ; } else if ( X == 2 && Y == 4 ) { swap ( N , M , mat , 0 , M / 2 , N / 2 , M / 2 ) ; } else if ( X == 3 && Y == 4 ) { swap ( N , M , mat , N / 2 , 0 , N / 2 , M / 2 ) ; } printMat ( N , M , mat ) ; } static void printMat ( int N , int M , int mat [ ] [ ] ) { for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < M ; j ++ ) { System . out . print ( mat [ i ] [ j ] + " ▁ " ) ; } System . out . println ( ) ; } } public static void main ( String [ ] args ) { int N = 6 , M = 6 ; int [ ] [ ] mat = { { 1 , 2 , 3 , 4 , 5 , 6 } , { 7 , 8 , 9 , 10 , 11 , 12 } , { 13 , 14 , 15 , 16 , 17 , 18 } , { 19 , 20 , 21 , 22 , 23 , 24 } , { 25 , 26 , 27 , 28 , 29 , 30 } , { 31 , 32 , 33 , 34 , 35 , 36 } } ; int X = 1 , Y = 4 ; swapQuadOfMatrix ( N , M , mat , X , Y ) ; } }

Index/key variables: i, j
Accumulator variables: col, i, j, row
Iterator variables: i, j
Class/struct names: Main
Java program:
import java . util . * ; import java . util . Map . Entry ; class Node { int data ; int hd ; Node left , right ; public Node ( int key ) { data = key ; hd = Integer . MAX_VALUE ; left = right = null ; } } class Tree { Node root ; public Tree ( ) { } public Tree ( Node node ) { root = node ; } public void bottomView ( ) { if ( root == null ) return ; int hd = 0 ; Map < Integer , Integer > map = new TreeMap < > ( ) ; Queue < Node > queue = new LinkedList < Node > ( ) ; root . hd = hd ; queue . add ( root ) ; while ( ! queue . isEmpty ( ) ) { Node temp = queue . remove ( ) ; hd = temp . hd ; map . put ( hd , temp . data ) ; if ( temp . left != null ) { temp . left . hd = hd - 1 ; queue . add ( temp . left ) ; } if ( temp . right != null ) { temp . right . hd = hd + 1 ; queue . add ( temp . right ) ; } } Set < Entry < Integer , Integer > > set = map . entrySet ( ) ; Iterator < Entry < Integer , Integer > > iterator = set . iterator ( ) ; while ( iterator . hasNext ( ) ) { Map . Entry < Integer , Integer > me = iterator . next ( ) ; System . out . print ( me . getValue ( ) + " ▁ " ) ; } } } public class BottomView { public static void main ( String [ ] args ) { Node root = new Node ( 20 ) ; root . left = new Node ( 8 ) ; root . right = new Node ( 22 ) ; root . left . left = new Node ( 5 ) ; root . left . right = new Node ( 3 ) ; root . right . left = new Node ( 4 ) ; root . right . right = new Node ( 25 ) ; root . left . right . left = new Node ( 10 ) ; root . left . right . right = new Node ( 14 ) ; Tree tree = new Tree ( root ) ; System . out . println ( " Bottom ▁ view ▁ of ▁ the ▁ given ▁ binary ▁ tree : " ) ; tree . bottomView ( ) ; } }

Class/struct names: BottomView, Node, Tree
Java program:
import java . util . * ; class GFG { static void incrementCount ( int arr [ ] , int N ) { int mini = arr [ 0 ] - arr [ 1 ] ; for ( int i = 2 ; i < N ; i ++ ) { mini = Math . min ( mini , arr [ i - 1 ] - arr [ i ] ) ; } System . out . println ( mini ) ; } public static void main ( String [ ] args ) { int N = 3 ; int arr [ ] = { 12 , 8 , 4 } ; incrementCount ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static void countOperations ( int n , int k ) { int div = 2 * k + 1 ; if ( n / 2 <= k ) { System . out . print ( 1 + "NEW_LINE"); if ( n > k ) System . out . print ( k + 1 ) ; else System . out . print ( n ) ; } else { if ( n % div == 0 ) { int oprn = n / div ; System . out . print ( oprn + "NEW_LINE"); int pos = k + 1 ; System . out . print ( pos + " ▁ " ) ; for ( int i = 1 ; i <= oprn ; i ++ ) { System . out . print ( pos + " ▁ " ) ; pos += div ; } } else { int oprn = n / div + 1 ; System . out . print ( oprn + "NEW_LINE"); int pos = n % div ; if ( n % div > k ) pos -= k ; for ( int i = 1 ; i <= oprn ; i ++ ) { System . out . print ( pos + " ▁ " ) ; pos += div ; } } } } public static void main ( String [ ] args ) { String str = " edfreqwsazxet " ; char ch = ' $ ' ; int n = str . length ( ) ; int k = 4 ; countOperations ( n , k ) ; } }

Accumulator variables: i, pos
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void largestSubsequence ( char [ ] s ) { int maxi = 0 ; char prev1 ; for ( int i = 0 ; i < 10 ; i ++ ) { for ( int j = 0 ; j < 10 ; j ++ ) { if ( i != j ) { int len = 0 ; prev1 = ( char ) ( j + '0' ) ; for ( int k = 0 ; k < s . length ; k ++ ) { if ( s [ k ] == i + '0' && prev1 == j + '0' ) { prev1 = s [ k ] ; len ++ ; } else if ( s [ k ] == j + '0' && prev1 == i + '0' ) { prev1 = s [ k ] ; len ++ ; } } maxi = Math . max ( len , maxi ) ; } } } if ( maxi != 1 ) System . out . print ( maxi + "NEW_LINE"); else System . out . print ( 0 + "NEW_LINE"); } public static void main ( String [ ] args ) { String s = "1542745249842" ; largestSubsequence ( s . toCharArray ( ) ) ; } }

Index/key variables: k
Accumulator variables: i, j, k, len
Iterator variables: i, j, k
Class/struct names: GFG
Java program:
import java . io . * ; import java . lang . * ; import java . util . * ; class GFG { static class Node { int data ; int hd ; Node left , right ; public Node ( int key ) { data = key ; hd = Integer . MAX_VALUE ; left = right = null ; } } static void printBottomViewUtil ( Node root , int curr , int hd , TreeMap < Integer , int [ ] > m ) { if ( root == null ) return ; if ( ! m . containsKey ( hd ) ) { m . put ( hd , new int [ ] { root . data , curr } ) ; } else { int [ ] p = m . get ( hd ) ; if ( p [ 1 ] <= curr ) { p [ 1 ] = curr ; p [ 0 ] = root . data ; } m . put ( hd , p ) ; } printBottomViewUtil ( root . left , curr + 1 , hd - 1 , m ) ; printBottomViewUtil ( root . right , curr + 1 , hd + 1 , m ) ; } static void printBottomView ( Node root ) { TreeMap < Integer , int [ ] > m = new TreeMap < > ( ) ; printBottomViewUtil ( root , 0 , 0 , m ) ; for ( int val [ ] : m . values ( ) ) { System . out . print ( val [ 0 ] + " ▁ " ) ; } } public static void main ( String [ ] args ) { Node root = new Node ( 20 ) ; root . left = new Node ( 8 ) ; root . right = new Node ( 22 ) ; root . left . left = new Node ( 5 ) ; root . left . right = new Node ( 3 ) ; root . right . left = new Node ( 4 ) ; root . right . right = new Node ( 25 ) ; root . left . right . left = new Node ( 10 ) ; root . left . right . right = new Node ( 14 ) ; System . out . println ( " Bottom ▁ view ▁ of ▁ the ▁ given ▁ binary ▁ tree : " ) ; printBottomView ( root ) ; } }

Class/struct names: GFG, Node
Java program:
import java . util . * ; class GFG { static int maxm = 0 ; static class Node { int val ; Node left , right ; Node ( int x ) { val = x ; left = null ; right = null ; } } ; static int gcd ( int a , int b ) { if ( b == 0 ) return a ; return gcd ( b , a % b ) ; } static int find_gcd ( Vector < Integer > arr ) { if ( arr . size ( ) == 1 ) return arr . get ( 0 ) ; int g = arr . get ( 0 ) ; for ( int i = 1 ; i < arr . size ( ) ; i ++ ) { g = gcd ( g , arr . get ( 1 ) ) ; } return g ; } static void maxm_gcd ( Node root , Vector < Integer > ans ) { if ( root == null ) return ; if ( root . left == null && root . right == null ) { ans . add ( root . val ) ; maxm = Math . max ( find_gcd ( ans ) , maxm ) ; return ; } ans . add ( root . val ) ; maxm_gcd ( root . left , ans ) ; maxm_gcd ( root . right , ans ) ; } public static void main ( String [ ] args ) { Node root = new Node ( 15 ) ; root . left = new Node ( 3 ) ; root . right = new Node ( 7 ) ; root . left . left = new Node ( 15 ) ; root . left . right = new Node ( 1 ) ; root . right . left = new Node ( 31 ) ; root . right . right = new Node ( 9 ) ; maxm_gcd ( root , new Vector < > ( ) ) ; System . out . print ( maxm + "NEW_LINE"); } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG, Node
Java program:
import java . io . * ; class GFG { public static int numberOfPairs ( int n ) { int count = 0 ; int i = 1 , j = n - 1 ; while ( i < j ) { if ( i + j == n ) { count ++ ; } i ++ ; j -- ; } return count ; } public static void main ( String [ ] args ) { int n = 8 ; System . out . println ( numberOfPairs ( n ) ) ; } }

Accumulator variables: count, i, j
Class/struct names: GFG
Java program:
import java . util . Arrays ; class GFG { static void Solve ( int N , int M ) { int temp = ( N - 1 ) * ( M - 1 ) ; int ans = ( int ) ( Math . pow ( 2 , temp ) ) ; if ( ( N + M ) % 2 != 0 ) System . out . print ( ans ) ; else System . out . print ( 2 * ans ) ; } public static void main ( String [ ] args ) { int N = 3 ; int M = 3 ; Solve ( N , M ) ; } }

Class/struct names: GFG