dhyuti-n/xlcost-variable-roles huggingface dataset:
Javascript program:
function minMaxRange ( arr , D , N ) { let max = 1 , min = N ; for ( let i = 0 ; i < N ; i ++ ) { let dist = leftSearch ( arr , arr [ i ] - D , i ) ; min = Math . min ( min , dist ) ; max = Math . max ( max , dist ) ; dist = rightSearch ( arr , arr [ i ] + D , i ) ; min = Math . min ( min , dist ) ; max = Math . max ( max , dist ) ; } return [ min , max ] ; } function leftSearch ( arr , val , i ) { if ( i == 0 ) return 1 ; let left = 0 , right = i - 1 ; let ind = - 1 ; while ( left <= right ) { let mid = Math . floor ( ( left + right ) / 2 ) ; if ( arr [ mid ] < val ) { left = mid + 1 ; } else { right = mid - 1 ; ind = mid ; } } return ind != - 1 ? i - ind + 1 : 1 ; } function rightSearch ( arr , val , i ) { if ( i == arr . length - 1 ) return 1 ; let left = i + 1 ; let right = arr . length - 1 ; let ind = - 1 ; while ( left <= right ) { let mid = Math . floor ( ( left + right ) / 2 ) ; if ( arr [ mid ] > val ) { right = mid - 1 ; } else { left = mid + 1 ; ind = mid ; } } return ind != - 1 ? ind - i + 1 : 1 ; } let arr = [ 1 , 3 , 5 , 9 , 14 ] ; let N = arr . length ; let D = 4 ; let minMax = minMaxRange ( arr , D , N ) ; document . write ( minMax [ 0 ] + " " + minMax [ 1 ] ) ;

Index/key variables: i, mid
Accumulator variables: i
Iterator variables: i
Javascript program:
function findPairs ( arr1 , arr2 , n , m , x ) { for ( let i = 0 ; i < n ; i ++ ) for ( let j = 0 ; j < m ; j ++ ) if ( arr1 [ i ] + arr2 [ j ] == x ) document . write ( arr1 [ i ] + " " + arr2 [ j ] + " " ) ; } let arr1 = [ 1 , 2 , 3 , 7 , 5 , 4 ] ; let arr2 = [ 0 , 7 , 4 , 3 , 2 , 1 ] ; let n = arr1 . length ; let m = arr2 . length ; let x = 8 ; findPairs ( arr1 , arr2 , n , m , x ) ;

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
function isvalid ( arr , K , N , M ) { let sum = 0 ; for ( let i = 0 ; i < N ; i ++ ) { sum += Math . ceil ( arr [ i ] * 1.0 / K ) ; } return sum <= M ; } function smallestValueForK ( arr , N , M ) { let low = 1 ; let high = Number . MIN_VALUE ; for ( let i = 0 ; i < N ; i ++ ) { high = Math . max ( high , arr [ i ] ) ; } let mid ; while ( high - low > 1 ) { mid = ( high + low ) / 2 ; if ( ! isvalid ( arr , mid , N , M ) ) low = mid + 1 ; else high = mid ; } return isvalid ( arr , low , N , M ) ? low : high ; } let arr = [ 4 , 3 , 2 , 7 ] ; let N = arr . length ; let M = 5 ; document . write ( smallestValueForK ( arr , N , M ) ) ;

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Javascript program:
function findPairs ( arr1 , arr2 , n , m , x ) { let s = new Map ( ) ; for ( let i = 0 ; i < n ; i ++ ) s . set ( arr1 [ i ] , 0 ) ; for ( let j = 0 ; j < m ; j ++ ) if ( s . has ( x - arr2 [ j ] ) ) document . write ( x - arr2 [ j ] + " " + arr2 [ j ] + " " ) ; } let arr1 = [ 1 , 0 , - 4 , 7 , 6 , 4 ] ; let arr2 = [ 0 , 2 , 4 , - 3 , 2 , 1 ] ; let x = 8 ; findPairs ( arr1 , arr2 , arr1 . length , arr2 . length , x ) ;

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
function findLargestIndex ( arr , n ) { for ( var i = n - 1 ; i >= 0 ; i -- ) { if ( arr [ i ] == i ) { document . write ( i ) ; return ; } } document . write ( - 1 ) ; } var arr = [ - 10 , - 5 , 0 , 3 , 7 ] ; var n = arr . length ; findLargestIndex ( arr , n ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function countFreq ( a , n ) { let hm = new Array ( n ) ; for ( let i = 0 ; i < hm . length ; i ++ ) { hm [ i ] = 0 ; } for ( let i = 0 ; i < n ; i ++ ) hm [ a [ i ] ] ++ ; let cumul = 0 ; for ( let i = 0 ; i < n ; i ++ ) { cumul += hm [ a [ i ] ] ; if ( hm [ a [ i ] ] != 0 ) { document . write ( a [ i ] + " " + cumul + " " ) ; } hm [ a [ i ] ] = 0 ; } } let a = [ 1 , 3 , 2 , 4 , 2 , 1 ] ; let n = a . length ; countFreq ( a , n ) ;

Index/key variables: i
Accumulator variables: cumul, i
Iterator variables: i
Javascript program:
function findPair ( arr , n ) { let found = false ; for ( let i = 0 ; i < n ; i ++ ) { for ( let j = i + 1 ; j < n ; j ++ ) { for ( let k = 0 ; k < n ; k ++ ) { if ( arr [ i ] + arr [ j ] == arr [ k ] ) { document . write ( arr [ i ] + " " + arr [ j ] + " " ) ; found = true ; } } } } if ( found == false ) document . write ( " " ) ; } let arr = [ 10 , 4 , 8 , 13 , 5 ] ; let n = arr . length ; findPair ( arr , n ) ;

Index/key variables: i, j, k
Accumulator variables: i, j, k
Iterator variables: i, j, k
Boolean variables: found
Javascript program:
function check ( n , m , x , y , vl ) { var temp = m ; if ( vl > n ) return false ; var ex = n - vl ; ex *= y ; temp += ex ; var cr = parseInt ( temp / x ) ; if ( cr >= vl ) return true ; return false ; } function maximizeMangoes ( n , m , x , y ) { var l = 0 , r = n ; var ans = 0 ; while ( l <= r ) { var mid = l + parseInt ( ( r - l ) / 2 ) ; if ( check ( n , m , x , y , mid ) ) { ans = mid ; l = mid + 1 ; } else r = mid - 1 ; } return ans ; } var W = 4 , C = 8 , x = 4 , y = 4 ; document . write ( maximizeMangoes ( W , C , x , y ) ) ;

Accumulator variables: ex, temp
Javascript program:
function findkthElement ( arr , n , K ) { var l = 0 ; var h = n - 1 , r ; while ( l + 1 < h ) { var mid = parseInt ( ( l + h ) / 2 ) ; if ( arr [ l ] >= arr [ mid ] ) l = mid ; else h = mid ; } if ( arr [ l ] < arr [ h ] ) r = l ; else r = h ; if ( K <= r + 1 ) return arr [ r + 1 - K ] ; else return arr [ n - ( K - ( r + 1 ) ) ] ; } var arr = [ 10 , 8 , 6 , 5 , 2 , 1 , 13 , 12 ] ; var n = arr . length ; var K = 3 ; document . write ( findkthElement ( arr , n , K ) ) ;

Index/key variables: h, l, mid
Javascript program:
function printPairs ( arr , n , k ) { let isPairFound = true ; for ( let i = 0 ; i < n ; i ++ ) { for ( let j = 0 ; j < n ; j ++ ) { if ( i != j && arr [ i ] % arr [ j ] == k ) { document . write ( " " + arr [ i ] + " " + arr [ j ] + " " + " " ) ; isPairFound = true ; } } } return isPairFound ; } let arr = [ 2 , 3 , 5 , 4 , 7 ] ; let k = 3 ; if ( printPairs ( arr , arr . length , k ) == false ) document . write ( " " ) ;

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Boolean variables: isPairFound
Javascript program:
function findDivisors ( n ) { let v = [ ] ; for ( let i = 1 ; i <= Math . sqrt ( n ) ; i ++ ) { if ( n % i == 0 ) { if ( n / i == i ) v . push ( i ) ; else { v . push ( i ) ; v . push ( Math . floor ( n / i ) ) ; } } } return v ; } function printPairs ( arr , n , k ) { let occ = new Map ( ) ; for ( let i = 0 ; i < n ; i ++ ) occ . set ( arr [ i ] , true ) ; let isPairFound = false ; for ( let i = 0 ; i < n ; i ++ ) { if ( occ . get ( k ) && k < arr [ i ] ) { document . write ( " " + k + " " + arr [ i ] + " " ) ; isPairFound = true ; } if ( arr [ i ] >= k ) { let v = findDivisors ( arr [ i ] - k ) ; for ( let j = 0 ; j < v . length ; j ++ ) { if ( arr [ i ] % v [ j ] == k && arr [ i ] != v [ j ] && occ . get ( v [ j ] ) ) { document . write ( " " + arr [ i ] + " " + v [ j ] + " " ) ; isPairFound = true ; } } v = [ ] ; } } return isPairFound ; } let arr = [ 3 , 1 , 2 , 5 , 4 ] ; let k = 2 ; if ( printPairs ( arr , arr . length , k ) == false ) document . write ( " " ) ;

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Boolean variables: isPairFound
Javascript program:
class Node { constructor ( item ) { this . val = item ; this . left = this . right = null ; } } let sum = 0 ; function rangeSumBST ( root , low , high ) { if ( root == null ) return 0 ; let q = [ ] ; q . push ( root ) ; while ( q . length != 0 ) { let curr = q . shift ( ) ; if ( curr . val >= low && curr . val <= high ) { sum += curr . val ; } if ( curr . left != null && curr . val > low ) q . push ( curr . left ) ; if ( curr . right != null && curr . val < high ) q . push ( curr . right ) ; } return sum ; } function insert ( node , data ) { if ( node == null ) return new Node ( data ) ; if ( data <= node . val ) node . left = insert ( node . left , data ) ; else node . right = insert ( node . right , data ) ; return node ; } let root = null ; root = insert ( root , 10 ) ; insert ( root , 5 ) ; insert ( root , 15 ) ; insert ( root , 3 ) ; insert ( root , 7 ) ; insert ( root , 18 ) ; let L = 7 , R = 15 ; document . write ( rangeSumBST ( root , L , R ) ) ;

Accumulator variables: sum
Class/struct names: Node
Javascript program:
function convert ( arr , n ) { let temp = [ ... arr ] ; temp . sort ( ( a , b ) => a - b ) ; let umap = new Map ( ) ; let val = 0 ; for ( let i = 0 ; i < n ; i ++ ) umap . set ( temp [ i ] , val ++ ) ; for ( let i = 0 ; i < n ; i ++ ) arr [ i ] = umap . get ( arr [ i ] ) ; } function prletArr ( arr , n ) { for ( let i = 0 ; i < n ; i ++ ) document . write ( arr [ i ] + " " ) ; } let arr = [ 10 , 20 , 15 , 12 , 11 , 50 ] ; let n = arr . length ; document . write ( " " + " " ) ; prletArr ( arr , n ) ; convert ( arr , n ) ; document . write ( " " + " " + " " ) ; prletArr ( arr , n ) ;

Index/key variables: i
Accumulator variables: i, val
Iterator variables: i
Javascript program:
function countSubstrings ( S , S1 , S2 ) { let N = S . length ; let N1 = S1 . length ; let N2 = S2 . length ; let count = 0 , totalcount = 0 ; for ( let i = 0 ; i < N ; i ++ ) { let prefix = S . substr ( i , N1 ) ; let suffix = S . substr ( i , N2 ) ; if ( S1 == prefix ) count ++ ; if ( S2 == suffix ) totalcount += count ; } return totalcount ; } function checkSubstrings ( S , S1 , S2 ) { let x = countSubstrings ( S , S1 , S2 ) ; let y = countSubstrings ( S , S2 , S1 ) ; if ( x == y ) document . write ( " " ) ; else document . write ( " " ) ; } let S = " " ; let S1 = " " ; let S2 = " " ; checkSubstrings ( S , S1 , S2 ) ;

Accumulator variables: count, i, totalcount
Iterator variables: i
Javascript program:
let ASCII_SIZE = 256 ; function getMaxOccuringChar ( str ) { let count = new Array ( ASCII_SIZE ) ; for ( let i = 0 ; i < ASCII_SIZE ; i ++ ) { count [ i ] = 0 ; } let len = str . length ; for ( let i = 0 ; i < len ; i ++ ) { count [ str [ i ] . charCodeAt ( 0 ) ] += 1 ; } let max = - 1 ; let result = ' ' ; for ( let i = 0 ; i < len ; i ++ ) { if ( max < count [ str [ i ] . charCodeAt ( 0 ) ] ) { max = count [ str [ i ] . charCodeAt ( 0 ) ] ; result = str [ i ] ; } } return result ; } let str = " " ; document . write ( " " , getMaxOccuringChar ( str ) ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function totalCount ( A , N , M , queries , Q ) { let row_sum = new Array ( N ) ; let col_sum = new Array ( M ) ; for ( let i = 0 ; i < N ; i ++ ) row_sum [ i ] = 0 ; for ( let j = 0 ; j < M ; j ++ ) col_sum [ j ] = 0 ; for ( let i = 0 ; i < N ; i ++ ) { for ( let j = 0 ; j < M ; j ++ ) { row_sum [ i ] += A [ i ] [ j ] ; col_sum [ j ] += A [ i ] [ j ] ; } } let sum_list = [ ] ; for ( let i = 0 ; i < N ; i ++ ) sum_list . push ( row_sum [ i ] ) ; for ( let i = 0 ; i < M ; i ++ ) sum_list . push ( col_sum [ i ] ) ; ( sum_list ) . sort ( function ( a , b ) { return a - b ; } ) ; for ( let i = 0 ; i < Q ; i ++ ) { let L = queries [ i ] [ 0 ] ; let R = queries [ i ] [ 1 ] ; let l = left_search ( sum_list , L ) ; let r = right_search ( sum_list , R ) ; document . write ( r - l + 1 + " " ) ; } } function left_search ( A , num ) { let low = 0 , high = A . length - 1 ; let ans = 0 ; while ( low <= high ) { let mid = low + Math . floor ( ( high - low ) / 2 ) ; if ( A [ mid ] >= num ) { ans = mid ; high = mid - 1 ; } else { low = mid + 1 ; } } return ans ; } function right_search ( A , num ) { let low = 0 , high = A . length - 1 ; let ans = high ; while ( low <= high ) { let mid = low + Math . floor ( ( high - low ) / 2 ) ; if ( A [ mid ] <= num ) { ans = mid ; low = mid + 1 ; } else { high = mid - 1 ; } } return ans ; } let N = 3 , M = 2 ; let A = [ [ 13 , 3 ] , [ 9 , 4 ] , [ 6 , 10 ] ] ; let Q = 2 ; let queries = [ [ 10 , 20 ] , [ 25 , 35 ] ] ; totalCount ( A , N , M , queries , Q ) ;

Index/key variables: i, j, mid
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
function maximumProfit ( arr , n ) { var ans = - 100000 ; ; var price = 0 ; for ( var i = 0 ; i < n ; i ++ ) { var count = 0 ; for ( var j = 0 ; j < n ; j ++ ) { if ( arr [ i ] <= arr [ j ] ) { count ++ ; } } if ( ans < count * arr [ i ] ) { price = arr [ i ] ; ans = count * arr [ i ] ; } } return price ; } arr = [ 22 , 87 , 9 , 50 , 56 , 43 ] ; document . write ( maximumProfit ( arr , 6 ) ) ;

Index/key variables: i, j
Accumulator variables: count, i, j
Iterator variables: i, j
Javascript program:
function print ( arr , N ) { for ( i = 0 ; i < N ; i ++ ) { document . write ( arr [ i ] + " " ) ; } } function makeLexicographically ( arr , N ) { var index = 0 ; var temp = 0 ; var check = 0 ; var condition = 0 ; var element = 0 ; for ( i = 0 ; i < N ; ++ i ) { if ( element == arr [ i ] ) { check = i ; break ; } else if ( arr [ i ] != i + 1 && check == 0 ) { index = i ; check = 1 ; condition = - 1 ; element = i + 1 ; } } if ( condition == - 1 ) { temp = arr [ index ] ; arr [ index ] = arr [ check ] ; arr [ check ] = temp ; } print ( arr , N ) ; } var arr = [ 1 , 2 , 3 , 4 ] var N = arr . length ; makeLexicographically ( arr , N ) ;

Index/key variables: check, i, index
Accumulator variables: i
Iterator variables: i
Javascript program:
function check ( N ) { if ( N == 0 ) return 0 ; return ! ( N & ( N - 1 ) ) ; } function build_seg_tree ( ss , se , si , tree , arr ) { if ( ss == se ) { tree [ si ] = check ( arr [ ss ] ) ; return ; } var mid = parseInt ( ( ss + se ) / 2 ) ; build_seg_tree ( ss , mid , 2 * si + 1 , tree , arr ) ; build_seg_tree ( mid + 1 , se , 2 * si + 2 , tree , arr ) ; tree [ si ] = tree [ 2 * si + 1 ] + tree [ 2 * si + 2 ] ; } function update ( ss , se , si , X , V , tree , arr ) { if ( ss == se ) { if ( ss == X ) { arr [ X ] = V ; tree [ si ] = check ( V ) ; } return ; } var mid = parseInt ( ( ss + se ) / 2 ) ; if ( X <= mid ) update ( ss , mid , 2 * si + 1 , X , V , tree , arr ) ; else update ( mid + 1 , se , 2 * si + 2 , X , V , tree , arr ) ; tree [ si ] = tree [ 2 * si + 1 ] + tree [ 2 * si + 2 ] ; } function query ( l , r , ss , se , si , tree ) { if ( r < ss l > se ) return 0 ; if ( l <= ss && r >= se ) return tree [ si ] ; var mid = parseInt ( ( ss + se ) / 2 ) ; return query ( l , r , ss , mid , 2 * si + 1 , tree ) + query ( l , r , mid + 1 , se , 2 * si + 2 , tree ) ; } function Query ( arr , N , Q ) { var tree = new Array ( 4 * N ) ; tree . fill ( 0 ) ; build_seg_tree ( 0 , N - 1 , 0 , tree , arr ) ; for ( var i = 0 ; i < Q . length ; i ++ ) { if ( Q [ i ] [ 0 ] == 1 ) document . write ( query ( Q [ i ] [ 1 ] , Q [ i ] [ 2 ] , 0 , N - 1 , 0 , tree ) + " " ) ; else update ( 0 , N - 1 , 0 , Q [ i ] [ 1 ] , Q [ i ] [ 2 ] , tree , arr ) ; } } var arr = [ 12 , 11 , 16 , 2 , 32 ] ; var Q = [ [ 1 , 0 , 2 ] , [ 2 , 4 , 24 ] , [ 1 , 1 , 4 ] ] ; var N = arr . length ; Query ( arr , N , Q ) ;

Index/key variables: X, i, si, ss
Accumulator variables: i
Iterator variables: i
Javascript program:
function findSum ( arr , n ) { arr . sort ( ) ; let sum = 0 ; for ( let i = 0 ; i < n ; i ++ ) { if ( arr [ i ] != arr [ i + 1 ] ) sum = sum + arr [ i ] ; } return sum ; } let arr = [ 1 , 2 , 3 , 1 , 1 , 4 , 5 , 6 ] ; let n = arr . length ; document . write ( findSum ( arr , n ) ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
let MARKER = ' ' ; class Node { constructor ( data ) { this . data = data ; } } function dupSubUtil ( root , subtrees ) { let s = " " ; if ( root == null ) return s + MARKER ; let lStr = dupSubUtil ( root . left , subtrees ) ; if ( lStr == ( s ) ) return s ; let rStr = dupSubUtil ( root . right , subtrees ) ; if ( rStr == ( s ) ) return s ; s = s + root . data + lStr + rStr ; if ( s . length > 3 && subtrees . has ( s ) ) return " " ; subtrees . add ( s ) ; return s ; } function dupSub ( root ) { let subtrees = new Set ( ) ; return dupSubUtil ( root , subtrees ) ; } let root = new Node ( ' ' ) ; root . left = new Node ( ' ' ) ; root . right = new Node ( ' ' ) ; root . left . left = new Node ( ' ' ) ; root . left . right = new Node ( ' ' ) ; root . right . right = new Node ( ' ' ) ; root . right . right . right = new Node ( ' ' ) ; root . right . right . left = new Node ( ' ' ) ; let str = dupSub ( root ) ; if ( str == ( " " ) ) document . write ( " " ) ; else document . write ( " " ) ;

Class/struct names: Node
Javascript program:
function minOperationNeeded ( str ) { str = modstring ( str ) ; var N = str . length ; var res = new Array ( 256 ) . fill ( 0 ) ; for ( var i = 0 ; i < N ; ++ i ) { res [ str [ i ] . charCodeAt ( 0 ) ] += 1 ; } res [ str [ 0 ] . charCodeAt ( 0 ) ] -= 1 ; res [ str [ N - 1 ] . charCodeAt ( 0 ) ] -= 1 ; var ans = 2147483647 ; for ( var i = 0 ; i < N ; ++ i ) { ans = Math . min ( ans , res [ str [ i ] . charCodeAt ( 0 ) ] ) ; } document . write ( ans + 1 + " " ) ; } function modstring ( str ) { var s = " " ; var b = true ; for ( var i = 1 ; i < str . length ; ++ i ) { if ( str [ i - 1 ] !== str [ i ] ) b = true ; if ( b ) { s += str [ i - 1 ] ; b = false ; } } return s . split ( " " ) ; } var str = " " ; minOperationNeeded ( str . split ( " " ) ) ;

Index/key variables: i
Accumulator variables: s
Iterator variables: i
Boolean variables: b
Javascript program:
class Node { constructor ( x ) { this . data = x ; this . child = [ ] ; } } function printPath ( vec ) { for ( let ele = 0 ; ele < vec . length ; ele ++ ) { document . write ( vec [ ele ] + " " ) ; } document . write ( " " ) ; } function printAllRootToLeafPaths ( root , vec ) { if ( root == null ) return ; vec . push ( root . data ) ; if ( root . child . length == 0 ) { printPath ( vec ) ; vec . pop ( ) ; return ; } for ( let i = 0 ; i < root . child . length ; i ++ ) printAllRootToLeafPaths ( root . child [ i ] , vec ) ; vec . pop ( ) ; } function printAllRootToLeaf_Paths ( root ) { if ( root == null ) return ; let vec = [ ] ; printAllRootToLeafPaths ( root , vec ) ; } let root = new Node ( 1 ) ; ( root . child ) . push ( new Node ( 2 ) ) ; ( root . child ) . push ( new Node ( 3 ) ) ; ( root . child [ 0 ] . child ) . push ( new Node ( 4 ) ) ; ( root . child [ 1 ] . child ) . push ( new Node ( 5 ) ) ; ( root . child [ 1 ] . child ) . push ( new Node ( 6 ) ) ; ( root . child [ 1 ] . child [ 1 ] . child ) . push ( new Node ( 7 ) ) ; ( root . child [ 1 ] . child [ 1 ] . child ) . push ( new Node ( 8 ) ) ; printAllRootToLeaf_Paths ( root ) ;

Index/key variables: ele, i
Accumulator variables: ele, i
Iterator variables: ele, i
Class/struct names: Node
Javascript program:
function minimumDeletions ( s ) { let n = s . length ; let zeroCount = [ ] ; zeroCount [ n - 1 ] = ( s [ n - 1 ] == ' ' ) ? 1 : 0 ; for ( let i = n - 2 ; i >= 0 ; i -- ) zeroCount [ i ] = ( s [ i ] == ' ' ) ? zeroCount [ i + 1 ] + 1 : zeroCount [ i + 1 ] ; let oneCount = 0 ; let ans = Number . MAX_VALUE ; for ( let i = 0 ; i < n ; i ++ ) { if ( s [ i ] == ' ' ) { ans = Math . min ( ans , oneCount + zeroCount [ i ] ) ; oneCount ++ ; } } ans = Math . min ( ans , oneCount ) ; return ( ans == Number . MAX_VALUE ) ? 0 : ans ; } let str = " " ; document . write ( minimumDeletions ( str ) ) ;

Index/key variables: i
Accumulator variables: i, oneCount
Iterator variables: i
Javascript program:
function printPairs ( arr , n ) { let v = [ ] ; for ( let i = 0 ; i < n ; i ++ ) for ( let j = i + 1 ; j < n ; j ++ ) if ( Math . abs ( arr [ i ] ) == Math . abs ( arr [ j ] ) ) v . push ( Math . abs ( arr [ i ] ) ) ; if ( v . length == 0 ) return ; v . sort ( function ( a , b ) { return a - b ; } ) ; for ( let i = 0 ; i < v . length ; i ++ ) document . write ( - v [ i ] + " " + v [ i ] ) ; } let arr = [ 4 , 8 , 9 , - 4 , 1 , - 1 , - 8 , - 9 ] ; let n = arr . length ; printPairs ( arr , n ) ;

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
function canPairs ( ar , k ) { if ( ar . length % 2 == 1 ) return false ; let hm = new Map ( ) ; for ( let i = 0 ; i < ar . length ; i ++ ) { let rem = ( ( ar [ i ] % k ) + k ) % k ; if ( ! hm . has ( rem ) ) { hm . set ( rem , 0 ) ; } hm . set ( rem , hm . get ( rem ) + 1 ) ; } for ( let i = 0 ; i < ar . length ; i ++ ) { let 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 ; } let arr = [ 92 , 75 , 65 , 48 , 45 , 35 ] ; let k = 10 ; let ans = canPairs ( arr , k ) ; if ( ans ) document . write ( " " ) ; else document . write ( " " ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function findTriplet ( a1 , a2 , a3 , n1 , n2 , n3 , sum ) { for ( var i = 0 ; i < n1 ; i ++ ) for ( var j = 0 ; j < n2 ; j ++ ) for ( var k = 0 ; k < n3 ; k ++ ) if ( a1 [ i ] + a2 [ j ] + a3 [ k ] == sum ) return true ; return false ; } var a1 = [ 1 , 2 , 3 , 4 , 5 ] ; var a2 = [ 2 , 3 , 6 , 1 , 2 ] ; var a3 = [ 3 , 2 , 4 , 5 , 6 ] ; var sum = 9 ; var n1 = a1 . length ; var n2 = a2 . length ; var n3 = a3 . length ; findTriplet ( a1 , a2 , a3 , n1 , n2 , n3 , sum ) ? document . write ( " " ) : document . write ( " " ) ;

Index/key variables: i, j, k
Accumulator variables: i, j, k
Iterator variables: i, j, k
Javascript program:
function countSum ( a , n , sum ) { var i , j , k , l ; var count = 0 ; for ( i = 0 ; i < n - 3 ; i ++ ) { for ( j = i + 1 ; j < n - 2 ; j ++ ) { var req = sum - a [ i ] - a [ j ] ; var m = new Map ( ) ; for ( k = j + 1 ; k < n ; k ++ ) { if ( m . has ( a [ k ] ) ) m . set ( a [ k ] , m . get ( a [ k ] ) + 1 ) else m . set ( a [ k ] , 1 ) } var twice_count = 0 ; for ( k = j + 1 ; k < n ; k ++ ) { if ( m . has ( req - a [ k ] ) ) twice_count += m . get ( req - a [ k ] ) ; if ( ( req - a [ k ] ) == a [ k ] ) twice_count -- ; } count += parseInt ( twice_count / 2 ) ; } } return count ; } var arr = [ 4 , 5 , 3 , 1 , 2 , 4 ] ; var S = 13 ; var N = arr . length ; document . write ( countSum ( arr , N , S ) ) ;

Index/key variables: i, j, k
Accumulator variables: count, i, j, k, twice_count
Iterator variables: i, j, k
Javascript program:
function check ( arr , n ) { for ( var i = 0 ; i < n ; i ++ ) { var hm = new Map ( ) ; var count = 0 ; for ( var j = i ; j < n ; j ++ ) { if ( hm . has ( arr [ j ] ) ) hm . set ( arr [ j ] , hm . get ( arr [ j ] ) + 1 ) else hm . set ( arr [ j ] , 1 ) if ( hm . get ( arr [ j ] ) == 1 ) count ++ ; if ( hm . get ( arr [ j ] ) == 2 ) count -- ; if ( count == 0 ) return " " ; } } return " " ; } var arr = [ 1 , 2 , 1 ] ; var N = arr . length ; document . write ( check ( arr , N ) ) ;

Index/key variables: j
Accumulator variables: count, i, j
Iterator variables: i, j
Javascript program:
function countPairsWithDiffK ( arr , N , K ) { var vis = new Array ( N ) ; vis . fill ( 0 ) ; var count = 0 ; for ( var i = 0 ; i < N ; i ++ ) { if ( vis [ i ] == 1 ) continue ; for ( var 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 ; } } } document . write ( count + " " ) ; } var arr = [ 1 , 3 , 3 , 5 ] ; var N = arr . length ; var K = 2 ; countPairsWithDiffK ( arr , N , K ) ;

Index/key variables: i, j
Accumulator variables: count, i, j
Iterator variables: i, j
Javascript program:
class Node { Node ( data ) { this . data = data ; this . left = this . right = null ; } } var a , b ; function areMirror ( a , 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 ) ; } a = new Node ( 1 ) ; b = new Node ( 1 ) ; left = new Node ( 2 ) ; right = new Node ( 3 ) ; left . left = new Node ( 4 ) ; left . right = new Node ( 5 ) ; left = new Node ( 3 ) ; right = new Node ( 2 ) ; right . left = new Node ( 5 ) ; right . right = new Node ( 4 ) ; if ( areMirror ( a , b ) == true ) document . write ( " " ) ; else document . write ( " " ) ;

Class/struct names: Node