dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
class GFG { static int firstNonRepeating ( int arr [ ] , int n ) { for ( int i = 0 ; i < n ; i ++ ) { int j ; for ( j = 0 ; j < n ; j ++ ) if ( i != j && arr [ i ] == arr [ j ] ) break ; if ( j == n ) return arr [ i ] ; } return - 1 ; } public static void main ( String [ ] args ) { int arr [ ] = { 9 , 4 , 9 , 6 , 7 , 4 } ; int n = arr . length ; System . out . print ( firstNonRepeating ( 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 { static int firstNonRepeating ( int arr [ ] , int n ) { Map < Integer , Integer > m = new HashMap < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( m . containsKey ( arr [ i ] ) ) { m . put ( arr [ i ] , m . get ( arr [ i ] ) + 1 ) ; } else { m . put ( arr [ i ] , 1 ) ; } } for ( int i = 0 ; i < n ; i ++ ) if ( m . get ( arr [ i ] ) == 1 ) return arr [ i ] ; return - 1 ; } public static void main ( String [ ] args ) { int arr [ ] = { 9 , 4 , 9 , 6 , 7 , 4 } ; int n = arr . length ; System . out . println ( firstNonRepeating ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void firstNonRepeating ( int arr [ ] , int n ) { Map < Integer , Integer > m = new HashMap < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( m . containsKey ( arr [ i ] ) ) { m . put ( arr [ i ] , m . get ( arr [ i ] ) + 1 ) ; } else { m . put ( arr [ i ] , 1 ) ; } } for ( Map . Entry < Integer , Integer > x : m . entrySet ( ) ) if ( x . getValue ( ) == 1 ) System . out . print ( x . getKey ( ) + " ▁ " ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 9 , 4 , 9 , 6 , 7 , 4 } ; int n = arr . length ; firstNonRepeating ( arr , n ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void minOperationNeeded ( char [ ] str ) { str = modstring ( str ) ; int N = str . length ; int res [ ] = new int [ 256 ] ; for ( int i = 0 ; i < N ; ++ i ) { res [ str [ i ] ] += 1 ; } res [ str [ 0 ] ] -= 1 ; res [ str [ N - 1 ] ] -= 1 ; int ans = Integer . MAX_VALUE ; for ( int i = 0 ; i < N ; ++ i ) { ans = Math . min ( ans , res [ str [ i ] ] ) ; } System . out . print ( ( ans + 1 ) + "NEW_LINE"); } private static char [ ] modstring ( char [ ] str ) { String s = " " ; boolean b = true ; for ( int i = 1 ; i < str . length ; ++ i ) { if ( str [ i - 1 ] != str [ i ] ) b = true ; if ( b ) { s += str [ i - 1 ] ; b = false ; } } return s . toCharArray ( ) ; } public static void main ( String [ ] args ) { String str = " ABCDABCDABCDA " ; minOperationNeeded ( str . toCharArray ( ) ) ; } }

Index/key variables: i
Accumulator variables: s
Iterator variables: i
Boolean variables: b
Class/struct names: GFG
Java program:
import java . util . ArrayList ; class GFG { static class Node { int data ; ArrayList < Node > child ; public Node ( int x ) { this . data = x ; this . child = new ArrayList < > ( ) ; } } ; static void printPath ( ArrayList < Integer > vec ) { for ( int ele : vec ) { System . out . print ( ele + " ▁ " ) ; } System . out . println ( ) ; } static void printAllRootToLeafPaths ( Node root , ArrayList < Integer > vec ) { if ( root == null ) return ; vec . add ( root . data ) ; if ( root . child . isEmpty ( ) ) { printPath ( vec ) ; vec . remove ( vec . size ( ) - 1 ) ; return ; } for ( int i = 0 ; i < root . child . size ( ) ; i ++ ) printAllRootToLeafPaths ( root . child . get ( i ) , vec ) ; vec . remove ( vec . size ( ) - 1 ) ; } static void printAllRootToLeafPaths ( Node root ) { if ( root == null ) return ; ArrayList < Integer > vec = new ArrayList < > ( ) ; printAllRootToLeafPaths ( root , vec ) ; } public static void main ( String [ ] args ) { Node root = new Node ( 1 ) ; ( root . child ) . add ( new Node ( 2 ) ) ; ( root . child ) . add ( new Node ( 3 ) ) ; ( root . child . get ( 0 ) . child ) . add ( new Node ( 4 ) ) ; ( root . child . get ( 1 ) . child ) . add ( new Node ( 5 ) ) ; ( root . child . get ( 1 ) . child ) . add ( new Node ( 6 ) ) ; ( root . child . get ( 1 ) . child . get ( 1 ) . child ) . add ( new Node ( 7 ) ) ; ( root . child . get ( 1 ) . child . get ( 1 ) . child ) . add ( new Node ( 8 ) ) ; printAllRootToLeafPaths ( root ) ; } }

Accumulator variables: i
Iterator variables: ele, i
Class/struct names: GFG, Node
Java program:
import java . io . * ; class GFG { public static int minimumDeletions ( String s ) { int n = s . length ( ) ; int zeroCount [ ] = new int [ n ] ; zeroCount [ n - 1 ] = ( s . charAt ( n - 1 ) == '0' ) ? 1 : 0 ; for ( int i = n - 2 ; i >= 0 ; i -- ) zeroCount [ i ] = ( s . charAt ( i ) == '0' ) ? zeroCount [ i + 1 ] + 1 : zeroCount [ i + 1 ] ; int oneCount = 0 ; int ans = Integer . MAX_VALUE ; for ( int i = 0 ; i < n ; i ++ ) { if ( s . charAt ( i ) == '1' ) { ans = Math . min ( ans , oneCount + zeroCount [ i ] ) ; oneCount ++ ; } } ans = Math . min ( ans , oneCount ) ; return ( ans == Integer . MAX_VALUE ) ? 0 : ans ; } public static void main ( String [ ] args ) { String str = "00101101" ; System . out . println ( minimumDeletions ( str ) ) ; } }

Index/key variables: i, n
Accumulator variables: i, oneCount
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; import java . lang . * ; class GFG { public static void printPairs ( int arr [ ] , int n ) { Vector < Integer > v = new Vector < Integer > ( ) ; for ( int i = 0 ; i < n ; i ++ ) for ( int j = i + 1 ; j < n ; j ++ ) if ( Math . abs ( arr [ i ] ) == Math . abs ( arr [ j ] ) ) v . add ( Math . abs ( arr [ i ] ) ) ; if ( v . size ( ) == 0 ) return ; Collections . sort ( v ) ; for ( int i = 0 ; i < v . size ( ) ; i ++ ) System . out . print ( - v . get ( i ) + " ▁ " + v . get ( i ) ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 4 , 8 , 9 , - 4 , 1 , - 1 , - 8 , - 9 } ; int n = arr . length ; printPairs ( arr , n ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . HashMap ; public class Divisiblepair { static boolean canPairs ( int ar [ ] , int k ) { if ( ar . length % 2 == 1 ) return false ; HashMap < Integer , Integer > hm = new HashMap < > ( ) ; for ( int i = 0 ; i < ar . length ; i ++ ) { int rem = ( ( ar [ i ] % k ) + k ) % k ; if ( ! hm . containsKey ( rem ) ) { hm . put ( rem , 0 ) ; } hm . put ( rem , hm . get ( rem ) + 1 ) ; } for ( int i = 0 ; i < ar . length ; i ++ ) { int rem = ( ( ar [ i ] % k ) + k ) % k ; if ( 2 * rem == k ) { if ( hm . get ( rem ) % 2 == 1 ) return false ; } else if ( rem == 0 ) { if ( hm . get ( rem ) % 2 == 1 ) return false ; } else { if ( hm . get ( k - rem ) != hm . get ( rem ) ) return false ; } } return true ; } public static void main ( String [ ] args ) { int arr [ ] = { 92 , 75 , 65 , 48 , 45 , 35 } ; int k = 10 ; boolean ans = canPairs ( arr , k ) ; if ( ans ) System . out . println ( " True " ) ; else System . out . println ( " False " ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: Divisiblepair
Java program:
import java . io . * ; import java . util . * ; public class GFG { static void subarrayDivisibleByK ( int [ ] arr , int n , int k ) { int [ ] mp = new int [ 1000 ] ; int s = 0 , e = 0 , maxs = 0 , maxe = 0 ; mp [ arr [ 0 ] % k ] ++ ; for ( int i = 1 ; i < n ; i ++ ) { int mod = arr [ i ] % k ; while ( mp [ k - mod ] != 0 || ( mod == 0 && mp [ mod ] != 0 ) ) { mp [ arr [ s ] % k ] -- ; s ++ ; } mp [ mod ] ++ ; e ++ ; if ( ( e - s ) > ( maxe - maxs ) ) { maxe = e ; maxs = s ; } } System . out . print ( " The ▁ maximum ▁ size ▁ is ▁ " + ( maxe - maxs + 1 ) + " and the subarray is as followsNEW_LINE"); for ( int i = maxs ; i <= maxe ; i ++ ) System . out . print ( arr [ i ] + " ▁ " ) ; } public static void main ( String args [ ] ) { int k = 3 ; int [ ] arr = { 5 , 10 , 15 , 20 , 25 } ; int n = arr . length ; subarrayDivisibleByK ( arr , n , k ) ; } }

Index/key variables: i, mod, s
Accumulator variables: e, i, s
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static boolean findTriplet ( int a1 [ ] , int a2 [ ] , int a3 [ ] , int n1 , int n2 , int n3 , int sum ) { for ( int i = 0 ; i < n1 ; i ++ ) for ( int j = 0 ; j < n2 ; j ++ ) for ( int k = 0 ; k < n3 ; k ++ ) if ( a1 [ i ] + a2 [ j ] + a3 [ k ] == sum ) return true ; return false ; } public static void main ( String [ ] args ) { int a1 [ ] = { 1 , 2 , 3 , 4 , 5 } ; int a2 [ ] = { 2 , 3 , 6 , 1 , 2 } ; int a3 [ ] = { 3 , 2 , 4 , 5 , 6 } ; int sum = 9 ; int n1 = a1 . length ; int n2 = a2 . length ; int n3 = a3 . length ; if ( findTriplet ( a1 , a2 , a3 , n1 , n2 , n3 , sum ) ) System . out . print ( " Yes " ) ; else System . out . print ( " No " ) ; } }

Index/key variables: i, j, k
Accumulator variables: i, j, k
Iterator variables: i, j, k
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static boolean findTriplet ( int a1 [ ] , int a2 [ ] , int a3 [ ] , int n1 , int n2 , int n3 , int sum ) { HashSet < Integer > s = new HashSet < Integer > ( ) ; for ( int i = 0 ; i < n1 ; i ++ ) { s . add ( a1 [ i ] ) ; } ArrayList < Integer > al = new ArrayList < > ( s ) ; for ( int i = 0 ; i < n2 ; i ++ ) { for ( int j = 0 ; j < n3 ; j ++ ) { if ( al . contains ( sum - a2 [ i ] - a3 [ j ] ) & al . indexOf ( sum - a2 [ i ] - a3 [ j ] ) != al . get ( al . size ( ) - 1 ) ) { return true ; } } } return false ; } public static void main ( String [ ] args ) { int a1 [ ] = { 1 , 2 , 3 , 4 , 5 } ; int a2 [ ] = { 2 , 3 , 6 , 1 , 2 } ; int a3 [ ] = { 3 , 2 , 4 , 5 , 6 } ; int sum = 9 ; int n1 = a1 . length ; int n2 = a2 . length ; int n3 = a3 . length ; if ( findTriplet ( a1 , a2 , a3 , n1 , n2 , n3 , sum ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int countSum ( int a [ ] , int n , int sum ) { int i , j , k , l ; int count = 0 ; for ( i = 0 ; i < n - 3 ; i ++ ) { for ( j = i + 1 ; j < n - 2 ; j ++ ) { int req = sum - a [ i ] - a [ j ] ; HashMap < Integer , Integer > m = new HashMap < > ( ) ; for ( k = j + 1 ; k < n ; k ++ ) if ( m . containsKey ( a [ k ] ) ) { m . put ( a [ k ] , m . get ( a [ k ] ) + 1 ) ; } else { m . put ( a [ k ] , 1 ) ; } int twice_count = 0 ; for ( k = j + 1 ; k < n ; k ++ ) { if ( m . containsKey ( req - a [ k ] ) ) twice_count += m . get ( req - a [ k ] ) ; if ( req - a [ k ] == a [ k ] ) twice_count -- ; } count += twice_count / 2 ; } } return count ; } public static void main ( String [ ] args ) { int arr [ ] = { 4 , 5 , 3 , 1 , 2 , 4 } ; int S = 13 ; int N = arr . length ; System . out . print ( countSum ( arr , N , S ) ) ; } }

Index/key variables: i, j, k
Accumulator variables: count, i, j, k, twice_count
Iterator variables: i, j, k
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class ArrayElements { class pair { int first , second ; pair ( int f , int s ) { first = f ; second = s ; } } ; boolean findPairs ( int arr [ ] ) { HashMap < Integer , pair > map = new HashMap < Integer , pair > ( ) ; int n = arr . length ; for ( int i = 0 ; i < n ; ++ i ) { for ( int j = i + 1 ; j < n ; ++ j ) { int sum = arr [ i ] + arr [ j ] ; if ( ! map . containsKey ( sum ) ) map . put ( sum , new pair ( i , j ) ) ; else { pair p = map . get ( sum ) ; System . out . println ( " ( " + arr [ p . first ] + " , ▁ " + arr [ p . second ] + " ) ▁ and ▁ ( " + arr [ i ] + " , ▁ " + arr [ j ] + " ) " ) ; return true ; } } } return false ; } public static void main ( String args [ ] ) { int arr [ ] = { 3 , 4 , 7 , 1 , 2 , 9 , 8 } ; ArrayElements a = new ArrayElements ( ) ; a . findPairs ( arr ) ; } }

Index/key variables: i, j
Iterator variables: i, j
Class/struct names: ArrayElements, pair
Java program:
import java . util . * ; import java . lang . * ; class GFG { static String check ( int arr [ ] , int n ) { for ( int i = 0 ; i < n ; i ++ ) { Map < Integer , Integer > hm = new HashMap < > ( ) ; int count = 0 ; for ( int j = i ; j < n ; j ++ ) { hm . put ( arr [ j ] , hm . getOrDefault ( arr [ j ] , 0 ) + 1 ) ; if ( hm . get ( arr [ j ] ) == 1 ) count ++ ; if ( hm . get ( arr [ j ] ) == 2 ) count -- ; if ( count == 0 ) return " No " ; } } return " Yes " ; } public static void main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 1 } ; int N = arr . length ; System . out . println ( check ( arr , N ) ) ; } }

Index/key variables: j
Accumulator variables: count, i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void countPairsWithDiffK ( int arr [ ] , int N , int K ) { int [ ] vis = new int [ N ] ; Arrays . fill ( vis , 0 ) ; int count = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( vis [ i ] == 1 ) continue ; for ( int j = i + 1 ; j < N ; j ++ ) { if ( vis [ j ] == 1 ) continue ; if ( Math . abs ( arr [ i ] - arr [ j ] ) >= K ) { count ++ ; vis [ i ] = 1 ; vis [ j ] = 1 ; break ; } } } System . out . print ( count ) ; } public static void main ( String args [ ] ) { int arr [ ] = { 1 , 3 , 3 , 5 } ; int N = arr . length ; int K = 2 ; countPairsWithDiffK ( arr , N , K ) ; } }

Index/key variables: N, i, j
Accumulator variables: count, i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
class Node { int data ; Node left , right ; public Node ( int data ) { this . data = data ; left = right = null ; } } class BinaryTree { Node a , b ; boolean areMirror ( Node a , Node b ) { if ( a == null && b == null ) return true ; if ( a == null b == null ) return false ; return a . data == b . data && areMirror ( a . left , b . right ) && areMirror ( a . right , b . left ) ; } public static void main ( String [ ] args ) { BinaryTree tree = new BinaryTree ( ) ; Node a = new Node ( 1 ) ; Node b = new Node ( 1 ) ; a . left = new Node ( 2 ) ; a . right = new Node ( 3 ) ; a . left . left = new Node ( 4 ) ; a . left . right = new Node ( 5 ) ; b . left = new Node ( 3 ) ; b . right = new Node ( 2 ) ; b . right . left = new Node ( 5 ) ; b . right . right = new Node ( 4 ) ; if ( tree . areMirror ( a , b ) == true ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } }

Class/struct names: BinaryTree, Node
Java program:
import java . util . HashMap ; class MaxLenZeroSumSub { static int maxLen ( int arr [ ] ) { HashMap < Integer , Integer > hM = new HashMap < Integer , Integer > ( ) ; int sum = 0 ; int max_len = 0 ; for ( int i = 0 ; i < arr . length ; i ++ ) { sum += arr [ i ] ; if ( arr [ i ] == 0 && max_len == 0 ) max_len = 1 ; if ( sum == 0 ) max_len = i + 1 ; Integer prev_i = hM . get ( sum ) ; if ( prev_i != null ) max_len = Math . max ( max_len , i - prev_i ) ; else hM . put ( sum , i ) ; } return max_len ; } public static void main ( String arg [ ] ) { int arr [ ] = { 15 , - 2 , 2 , - 8 , 1 , 7 , 10 , 23 } ; System . out . println ( " Length ▁ of ▁ the ▁ longest ▁ 0 ▁ sum ▁ subarray ▁ is ▁ " + maxLen ( arr ) ) ; } }

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Class/struct names: MaxLenZeroSumSub
Java program:
import java . io . * ; class GFG { static void printAlter ( int [ ] arr , int N ) { for ( int currIndex = 0 ; currIndex < N ; currIndex += 2 ) { System . out . print ( arr [ currIndex ] + " ▁ " ) ; } } public static void main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 3 , 4 , 5 } ; int N = arr . length ; printAlter ( arr , N ) ; } }

Index/key variables: currIndex
Accumulator variables: currIndex
Iterator variables: currIndex
Class/struct names: GFG
Java program:
import java . util . * ; class lics { static int LongIncrConseqSubseq ( int arr [ ] , int n ) { HashMap < Integer , Integer > map = new HashMap < > ( ) ; map . put ( arr [ 0 ] , 1 ) ; for ( int i = 1 ; i < n ; i ++ ) { if ( map . containsKey ( arr [ i ] - 1 ) ) { map . put ( arr [ i ] , map . get ( arr [ i ] - 1 ) + 1 ) ; map . remove ( arr [ i ] - 1 ) ; } else { map . put ( arr [ i ] , 1 ) ; } } return Collections . max ( map . values ( ) ) ; } public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int arr [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) arr [ i ] = sc . nextInt ( ) ; System . out . println ( LongIncrConseqSubseq ( arr , n ) ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: lics
Java program:
import java . util . * ; class GFG { static int longLenSub ( int [ ] arr , int n ) { HashMap < Integer , Integer > um = new HashMap < Integer , Integer > ( ) ; int longLen = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int len = 0 ; if ( um . containsKey ( arr [ i ] - 1 ) && len < um . get ( arr [ i ] - 1 ) ) len = um . get ( arr [ i ] - 1 ) ; if ( um . containsKey ( arr [ i ] + 1 ) && len < um . get ( arr [ i ] + 1 ) ) len = um . get ( arr [ i ] + 1 ) ; um . put ( arr [ i ] , len + 1 ) ; if ( longLen < um . get ( arr [ i ] ) ) longLen = um . get ( arr [ i ] ) ; } return longLen ; } public static void main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 3 , 4 , 5 , 3 , 2 } ; int n = arr . length ; System . out . println ( " Longest ▁ length ▁ subsequence ▁ = ▁ " + longLenSub ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GfG { static int count = 0 ; static class Node { int val ; Node left , right ; } static void find ( Node root , int max ) { if ( root == null ) return ; if ( root . val >= max ) count ++ ; find ( root . left , Math . max ( max , root . val ) ) ; find ( root . right , Math . max ( max , root . val ) ) ; } static int NodesMaxInPath ( Node root ) { find ( root , Integer . MIN_VALUE ) ; return count ; } static Node newNode ( int data ) { Node temp = new Node ( ) ; temp . val = data ; temp . left = null ; temp . right = null ; return temp ; } public static void main ( String [ ] args ) { Node root = null ; root = newNode ( 3 ) ; root . left = newNode ( 2 ) ; root . right = newNode ( 5 ) ; root . left . left = newNode ( 4 ) ; root . right . right = newNode ( 7 ) ; int answer = NodesMaxInPath ( root ) ; System . out . println ( answer ) ; } }

Accumulator variables: count
Class/struct names: GfG, Node
Java program:
import java . io . * ; import java . util . * ; class GFG { static int findLongestConseqSubseq ( int arr [ ] , int n ) { Arrays . sort ( arr ) ; int ans = 0 , count = 0 ; ArrayList < Integer > v = new ArrayList < Integer > ( ) ; v . add ( 10 ) ; for ( int i = 1 ; i < n ; i ++ ) { if ( arr [ i ] != arr [ i - 1 ] ) v . add ( arr [ i ] ) ; } for ( int i = 0 ; i < v . size ( ) ; i ++ ) { if ( i > 0 && v . get ( i ) == v . get ( i - 1 ) + 1 ) count ++ ; else count = 1 ; ans = Math . max ( ans , count ) ; } return ans ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 9 , 3 , 10 , 4 , 20 , 2 } ; int n = arr . length ; System . out . println ( " Length ▁ of ▁ the ▁ Longest ▁ " + " contiguous ▁ subsequence ▁ is ▁ " + findLongestConseqSubseq ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int maxn = ( int ) 1e6 + 5 ; static int [ ] BITree = new int [ maxn ] ; static boolean is_prime ( int n ) { if ( n <= 1 ) return false ; for ( int i = 2 ; i * i <= n ; i ++ ) if ( n % i == 0 ) return false ; return true ; } static void update_bitree ( int BITree [ ] , int index , int value ) { while ( index <= maxn ) { BITree [ index ] += value ; index += ( index & ( - index ) ) ; } } static int sum_bitree ( int BITree [ ] , int index ) { int s = 0 ; while ( index > 0 ) { s += BITree [ index ] ; index -= ( index & ( - index ) ) ; } return s ; } static void countSmallerPrimes ( int BITree [ ] , int ar [ ] , int N ) { int [ ] ans = new int [ N ] ; for ( int i = N - 1 ; i >= 0 ; i -- ) { ans [ i ] = sum_bitree ( BITree , ar [ i ] ) ; if ( is_prime ( ar [ i ] ) ) update_bitree ( BITree , ar [ i ] , 1 ) ; } for ( int i = 0 ; i < N ; i ++ ) System . out . print ( ans [ i ] + " ▁ " ) ; } public static void main ( String [ ] args ) { int ar [ ] = { 5 , 5 , 17 , 9 , 12 , 15 , 11 , 7 , 39 , 3 } ; int N = ar . length ; countSmallerPrimes ( BITree , ar , N ) ; } }

Index/key variables: N, i, index, maxn
Accumulator variables: i, index, s
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class ArrayElements { static int findLongestConseqSubseq ( int arr [ ] , int n ) { HashSet < Integer > S = new HashSet < Integer > ( ) ; int ans = 0 ; for ( int i = 0 ; i < n ; ++ i ) S . add ( arr [ i ] ) ; for ( int i = 0 ; i < n ; ++ i ) { if ( ! S . contains ( arr [ i ] - 1 ) ) { int j = arr [ i ] ; while ( S . contains ( j ) ) j ++ ; if ( ans < j - arr [ i ] ) ans = j - arr [ i ] ; } } return ans ; } public static void main ( String args [ ] ) { int arr [ ] = { 1 , 9 , 3 , 10 , 4 , 20 , 2 } ; int n = arr . length ; System . out . println ( " Length ▁ of ▁ the ▁ Longest ▁ consecutive ▁ subsequence ▁ is ▁ " + findLongestConseqSubseq ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: j
Iterator variables: i
Class/struct names: ArrayElements
Java program:
import java . io . * ; import java . util . PriorityQueue ; public class Longset_Sub { static int findLongestConseqSubseq ( int arr [ ] , int N ) { PriorityQueue < Integer > pq = new PriorityQueue < Integer > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { pq . add ( arr [ i ] ) ; } int prev = pq . poll ( ) ; int c = 1 ; int max = 1 ; for ( int i = 1 ; i < N ; i ++ ) { if ( pq . peek ( ) - prev > 1 ) { c = 1 ; prev = pq . poll ( ) ; } else if ( pq . peek ( ) - prev == 0 ) { prev = pq . poll ( ) ; } else { c ++ ; prev = pq . poll ( ) ; } if ( max < c ) { max = c ; } } return max ; } public static void main ( String args [ ] ) throws IOException { int arr [ ] = { 1 , 9 , 3 , 10 , 4 , 20 , 2 } ; int n = arr . length ; System . out . println ( " Length ▁ of ▁ the ▁ Longest ▁ consecutive ▁ subsequence ▁ is ▁ " + findLongestConseqSubseq ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: c, i
Iterator variables: i
Class/struct names: Longset_Sub
Java program:
import java . util . * ; class GFG { static void print_kth_String ( String str , int K ) { StringTokenizer st = new StringTokenizer ( str ) ; int count = 1 ; while ( st . hasMoreTokens ( ) && K > 0 ) { if ( count == K ) System . out . println ( st . nextToken ( ) ) ; count ++ ; st . nextToken ( ) ; } } public static void main ( String [ ] args ) { String s = ( "10 ▁ 20 ▁ 30 ▁ 40" ) ; int K = 2 ; print_kth_String ( s , K ) ; } }

Accumulator variables: count
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void findLIS ( int A [ ] , int n ) { Map < Integer , Integer > hash = new HashMap < Integer , Integer > ( ) ; int LIS_size = 1 ; int LIS_index = 0 ; hash . put ( A [ 0 ] , 1 ) ; for ( int i = 1 ; i < n ; i ++ ) { hash . put ( A [ i ] , hash . get ( A [ i ] - 1 ) == null ? 1 : hash . get ( A [ i ] - 1 ) + 1 ) ; if ( LIS_size < hash . get ( A [ i ] ) ) { LIS_size = hash . get ( A [ i ] ) ; LIS_index = A [ i ] ; } } System . out . println ( " LIS _ size ▁ = ▁ " + LIS_size ) ; System . out . print ( " LIS ▁ : ▁ " ) ; int start = LIS_index - LIS_size + 1 ; while ( start <= LIS_index ) { System . out . print ( start + " ▁ " ) ; start ++ ; } } public static void main ( String [ ] args ) { int A [ ] = { 2 , 5 , 3 , 7 , 4 , 8 , 5 , 13 , 6 } ; int n = A . length ; findLIS ( A , n ) ; } }

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