dhyuti-n/xlcost-variable-roles huggingface dataset:
Javascript program:
let N = 3 , M = 3 ; function checkReverseBitonic ( arr , n ) { let i , j , f = 0 ; for ( i = 1 ; i < n ; i ++ ) { if ( arr [ i ] < arr [ i - 1 ] ) continue ; if ( arr [ i ] == arr [ i - 1 ] ) return false ; else { f = 1 ; break ; } } if ( i == n ) return true ; for ( j = i + 1 ; j < n ; j ++ ) { if ( arr [ j ] > arr [ j - 1 ] ) continue ; if ( arr [ i ] == arr [ i - 1 ] ) return false ; else { if ( f == 1 ) return false ; } } return true ; } function check ( arr ) { let f = 0 ; for ( let i = 0 ; i < N ; i ++ ) { if ( ! checkReverseBitonic ( arr [ i ] , M ) ) { document . write ( " " + " " ) ; return ; } } for ( let i = 0 ; i < N ; i ++ ) { let temp = [ N ] ; for ( let j = 0 ; j < N ; j ++ ) { temp [ j ] = arr [ j ] [ i ] ; } if ( ! checkReverseBitonic ( temp , N ) ) { document . write ( " " + " " ) ; return ; } } document . write ( " " ) ; } let m = [ [ 2 , 3 , 4 ] , [ 1 , 2 , 3 ] , [ 4 , 5 , 6 ] ] ; check ( m ) ;

Index/key variables: N, i, j
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
function string_modify ( s ) { var alphabets = Array ( 26 ) . fill ( 0 ) ; var flag = 0 , hold_i ; var hold_l ; var i ; for ( i = 0 ; i < 26 ; i ++ ) { alphabets [ i ] = String . fromCharCode ( i + ' ' . charCodeAt ( 0 ) ) ; } var difference = new Set ( ) ; var reconstruct = " " ; for ( var i = 1 ; i < s . length ; i ++ ) { difference . add ( s [ i ] . charCodeAt ( 0 ) - s [ i - 1 ] . charCodeAt ( 0 ) ) ; } if ( difference . size == 1 ) { document . write ( " " ) ; return ; } [ ... difference ] . sort ( ( a , b ) => a - b ) . forEach ( it => { if ( flag != 1 ) { var index = s [ 0 ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ; reconstruct = " " ; flag = 0 ; for ( var i = 0 ; i < s . length && flag <= 1 ; i ++ ) { reconstruct += alphabets [ index ] ; index += it ; if ( index < 0 ) { index += 26 ; } index %= 26 ; if ( reconstruct [ i ] != s [ i ] ) { flag ++ ; hold_i = i ; hold_l = s [ i ] ; } } if ( flag == 1 ) { s [ hold_i ] = reconstruct [ hold_i ] ; } } } ) ; if ( flag > 1 ) { hold_i = 0 ; hold_l = s [ 0 ] ; var temp = ( s [ 1 ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) - ( s [ 2 ] . charCodeAt ( 0 ) - s [ 1 ] . charCodeAt ( 0 ) ) ) % 26 ; if ( temp < 0 ) { temp += 26 ; } s [ 0 ] = alphabets [ temp ] ; } document . write ( hold_i + " " + hold_l + " " + s . join ( ' ' ) + " " ) ; } var s = " " ; string_modify ( s . split ( ' ' ) ) ;

Index/key variables: hold_i, i, index, temp
Accumulator variables: flag, i, index, reconstruct, temp
Iterator variables: i
Javascript program:
function evenSubMatrix ( N ) { let even = 1 ; let odd = 2 ; for ( let i = 0 ; i < N ; i ++ ) { for ( let j = 0 ; j < N ; j ++ ) { if ( ( i + j ) % 2 == 0 ) { document . write ( even + " " ) ; even += 2 ; } else { document . write ( odd + " " ) ; odd += 2 ; } } document . write ( " " ) ; } } let N = 4 ; evenSubMatrix ( N ) ;

Accumulator variables: even, i, j, odd
Iterator variables: i, j
Javascript program:
function maximum_inversion ( n , k ) { var answer = 0 ; k = Math . min ( k , parseInt ( n / 2 ) ) ; var left = 1 ; var right = n ; while ( k > 0 ) { k -- ; answer += 2 * ( right - left ) - 1 ; left ++ ; right -- ; } document . write ( answer + " " ) ; } var N = 5 ; var K = 3 ; maximum_inversion ( N , K ) ; N = 4 ; K = 1 ; maximum_inversion ( N , K ) ;

Accumulator variables: answer, k, left, right
Javascript program:
let N_bonacci = new Array ( 100 ) ; for ( let i = 0 ; i < 100 ; i ++ ) { N_bonacci [ i ] = 0 ; } function N_bonacci_nums ( n , k ) { N_bonacci [ 0 ] = 1 ; for ( let i = 1 ; i <= 50 ; ++ i ) { for ( let j = i - 1 ; j >= i - k && j >= 0 ; -- j ) N_bonacci [ i ] += N_bonacci [ j ] ; } let ans = [ ] ; for ( let i = 50 ; i >= 0 ; -- i ) if ( n - N_bonacci [ i ] >= 0 ) { ans . push ( N_bonacci [ i ] ) ; n -= N_bonacci [ i ] ; } if ( ans . length == 1 ) ans . push ( 0 ) ; document . write ( ans . length + " " ) ; for ( let i = 0 ; i < ans . length ; ++ i ) document . write ( ans [ i ] + " " ) ; } let n = 21 , k = 5 ; N_bonacci_nums ( n , k ) ;

Index/key variables: i, j
Accumulator variables: i, n
Iterator variables: i, j
Javascript program:
function checkBitonic ( s ) { var i , j ; for ( i = 1 ; i < s . length ; i ++ ) { if ( s [ i ] > s [ i - 1 ] ) continue ; if ( s [ i ] <= s [ i - 1 ] ) break ; } if ( i == s . length - 1 ) return 1 ; for ( j = i + 1 ; j < s . length ; j ++ ) { if ( s [ j ] < s [ j - 1 ] ) continue ; if ( s [ j ] >= s [ j - 1 ] ) break ; } i = j ; if ( i != s . length ) return 0 ; return 1 ; } var s = " " ; ( checkBitonic ( s ) == 1 ) ? document . write ( " " ) : document . write ( " " ) ;

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
function findArray ( a , n , P ) { let mi = Math . min ( ... a ) ; let ctr = 0 ; mi = Math . max ( 0 , mi - 1 ) ; for ( let i = 0 ; i < n ; i ++ ) { a [ i ] -= mi ; ctr += mi ; } let i = P - 1 ; let start = - 1 ; while ( true ) { if ( a [ i ] == 0 ) { start = i ; break ; } a [ i ] -= 1 ; ctr += 1 ; i = ( i - 1 + n ) % n ; } a [ start ] = ctr ; for ( i = 0 ; i < n ; i ++ ) { document . write ( a [ i ] + " " ) ; } } let N = 5 ; let P = 2 ; let arr = [ 3 , 2 , 0 , 2 , 7 ] ; findArray ( arr , N , P ) ;

Index/key variables: i, start
Accumulator variables: ctr, i
Iterator variables: i
Javascript program:
function makeArray ( n ) { for ( var i = 1 ; i <= n ; i ++ ) document . write ( i * n + " " ) ; } var N = 6 ; makeArray ( N ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function printOddFactorNumber ( n , m ) { for ( let i = n ; i <= m ; i ++ ) { if ( ( i > 0 ) && ( ( i & ( i - 1 ) ) != 0 ) ) document . write ( i + " " ) ; } return 0 ; } let N = 2 , M = 10 ; printOddFactorNumber ( N , M ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function printSeries ( n ) { let k = 2 ; for ( let i = 0 ; i < n ; i ++ ) { document . write ( ( k * ( 2 * k - 1 ) ) + " " ) ; k += 2 ; } document . writeln ( " " ) ; } let N = 12 ; printSeries ( N ) ;

Accumulator variables: i, k
Iterator variables: i
Javascript program:
function check_string_exist ( S ) { var size = S . length ; var check = true ; for ( var i = 0 ; i < size ; i ++ ) { if ( S [ i ] != S [ ( i + 2 ) % size ] ) { check = false ; break ; } } if ( check ) document . write ( " " ) ; else document . write ( " " ) ; } var S = " " ; check_string_exist ( S ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Boolean variables: check
Javascript program:
function getProduct ( n ) { var product = 1 ; while ( n != 0 ) { product = product * ( n % 10 ) ; n = parseInt ( n / 10 ) ; } return product ; } function productinRange ( l , r ) { if ( r - l > 9 ) return 0 ; else { var p = 1 ; for ( var i = l ; i <= r ; i ++ ) p *= getProduct ( i ) ; return p ; } } var l = 11 , r = 15 ; document . write ( productinRange ( l , r ) + " " ) ; l = 1 , r = 15 ; document . write ( productinRange ( l , r ) ) ;

Accumulator variables: i, p
Iterator variables: i
Javascript program:
function checkQwertyRow ( x ) { var first_row = [ " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , ] ; var second_row = [ " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , ] ; var third_row = [ " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , ] ; var fourth_row = [ " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , ] ; if ( first_row . includes ( x ) ) { return 1 ; } else if ( second_row . includes ( x ) ) { return 2 ; } else if ( third_row . includes ( x ) ) { return 3 ; } else if ( fourth_row . includes ( x ) ) { return 4 ; } return 0 ; } function checkValidity ( str ) { var x = str [ 0 ] ; var row = checkQwertyRow ( x ) ; for ( var i = 0 ; i < str . length ; i ++ ) { x = str [ i ] ; if ( row !== checkQwertyRow ( x ) ) { return false ; } } return true ; } var str = " " ; if ( checkValidity ( str ) ) document . write ( " " ) ; else document . write ( " " ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function fib ( n ) { var f0 = 0 ; var f1 = 1 ; if ( n == 0 ) return 0 ; if ( n == 1 ) return 1 ; else { var rem = parseInt ( ( n % 60 ) ) ; if ( rem == 0 ) return 0 ; for ( i = 2 ; i < rem + 3 ; i ++ ) { var f = ( f0 + f1 ) % 60 ; f0 = f1 ; f1 = f ; } var s = f1 - 1 ; return s ; } } var m = 10087887 ; var n = 2983097899 ; var Final = parseInt ( Math . abs ( fib ( n ) - fib ( m - 1 ) ) ) ; document . write ( Final % 10 ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function printSinX ( N ) { let Xi = 0 ; let num = 1 ; while ( N -- > 0 ) { document . write ( " " + num + " " + Xi ) ; document . write ( " " + num + " " ) ; document . write ( Math . sin ( Xi ) . toFixed ( 6 ) ) ; document . write ( " " ) ; num += 1 ; Xi += 710 ; } } let N = 5 ; printSinX ( N ) ;

Accumulator variables: N, Xi, num
Javascript program:
function sumBetweenZero ( arr , N ) { let i = 0 ; let A = new Array ( ) ; let sum = 0 ; for ( i = 0 ; i < N ; i ++ ) { if ( arr [ i ] == 0 ) { i ++ ; break ; } } for ( ; i < N ; i ++ ) { if ( arr [ i ] == 0 ) { A . push ( sum ) ; sum = 0 ; } else { sum += arr [ i ] ; } } for ( let i = 0 ; i < A . length ; i ++ ) { document . write ( A [ i ] + ' ' ) ; } if ( A . length == 0 ) document . write ( " " ) ; } let arr = [ 1 , 0 , 3 , 4 , 0 , 4 , 4 , 0 , 2 , 1 , 4 , 0 , 3 ] ; let N = arr . length ; sumBetweenZero ( arr , N ) ;

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Javascript program:
function maximumSubsequence ( arr , N ) { let M = new Map ( ) ; for ( let i = 0 ; i < N ; i ++ ) { if ( M . has ( arr [ i ] ) ) { M . set ( arr [ i ] , M . get ( arr [ i ] ) + 1 ) ; } else { M . set ( arr [ i ] , 1 ) ; } } let distinct_size = M . size ; let maxFreq = 1 ; for ( let it of M ) { maxFreq = Math . max ( maxFreq , it [ 1 ] ) ; } document . write ( Math . max ( Math . min ( distinct_size , maxFreq - 1 ) , Math . min ( distinct_size - 1 , maxFreq ) ) ) ; } let arr = [ 1 , 2 , 3 , 4 , 4 , 4 , 4 , 4 , 5 ] ; let N = arr . length ; maximumSubsequence ( arr , N ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i, it
Javascript program:
function countCharacters ( strings , chars ) { var res = 0 ; var freq = new Map ( ) ; for ( var i = 0 ; i < chars . length ; i ++ ) { if ( freq . has ( chars [ i ] ) ) freq . set ( chars [ i ] , freq . get ( chars [ i ] ) + 1 ) else freq . set ( chars [ i ] , 1 ) } strings . forEach ( st => { var flag = true ; st . split ( ' ' ) . forEach ( c => { if ( ! freq . has ( c ) ) { flag = false ; } } ) ; if ( flag ) res += st . length ; } ) ; return res ; } var strings = [ " " , " " , " " ] ; var chars = " " ; document . write ( countCharacters ( strings , chars ) ) ;

Index/key variables: i
Accumulator variables: i, res
Iterator variables: i
Boolean variables: flag
Javascript program:
function arrayConstruct ( N ) { for ( let i = 2 ; i <= N ; i = i + 2 ) document . write ( i + " " ) ; for ( let i = 1 ; i < N - 1 ; i = i + 2 ) document . write ( i + " " ) ; document . write ( N - 1 + ( N / 2 ) + " " ) ; } function createArray ( N ) { if ( N % 4 == 0 ) arrayConstruct ( N ) ; else document . write ( - 1 + " " ) ; } let N = 8 ; createArray ( N ) ;

Iterator variables: i
Javascript program:
function distinctSubstring ( P , Q , K , N ) { let S = new Set ( ) ; for ( let i = 0 ; i < N ; ++ i ) { let sum = 0 ; let s = " " ; for ( let j = i ; j < N ; ++ j ) { let pos = P [ j ] . charCodeAt ( ) - ' ' . charCodeAt ( ) ; sum += Q [ pos ] . charCodeAt ( ) - ' ' . charCodeAt ( ) ; s += P [ j ] ; if ( sum <= K ) { S . add ( s ) ; } else { break ; } } } return S . size ; } let S = " " ; let W = " " ; let K = 5 ; let N = S . length ; document . write ( distinctSubstring ( S , W , K , N ) ) ;

Index/key variables: j, pos
Accumulator variables: s, sum
Iterator variables: i, j
Javascript program:
function distinctSubString ( P , Q , K , N ) { let S = new Set ( ) ; for ( let i = 0 ; i < N ; ++ i ) { let sum = 0 ; let s = " " ; for ( let j = i ; j < N ; ++ j ) { let pos = P [ j ] . charCodeAt ( ) - ' ' . charCodeAt ( ) ; sum += Q [ pos ] . charCodeAt ( ) - ' ' . charCodeAt ( ) ; s += P [ j ] ; if ( sum <= K ) { S . add ( s ) ; } else { break ; } } } return S . size ; } let P = " " ; let Q = " " ; let K = 5 ; let N = P . length ; document . write ( distinctSubString ( P , Q , K , N ) ) ;

Index/key variables: j, pos
Accumulator variables: s, sum
Iterator variables: i, j
Javascript program:
function printPattern ( n ) { var i , j ; for ( i = 1 ; i <= n ; i ++ ) { for ( j = 1 ; j < 2 * n ; j ++ ) { if ( j == n - i + 1 j == n + i - 1 ) { document . write ( " " ) ; } else if ( i >= 4 && i <= n - 4 && ( j == n - i + 4 j == n + i - 4 ) ) { document . write ( " " ) ; } else if ( i == n || ( i == n - 4 && j >= n - ( n - 2 * 4 ) && j <= n + n - 2 * 4 ) ) { document . write ( " " ) ; } else { document . write ( " " ) ; document . write ( " " ) ; } } document . write ( " " ) ; } } var N = 9 ; printPattern ( N ) ;

Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
function isKAlternating ( s , k ) { if ( s . length < k ) return false ; var checker = 0 ; for ( var i = 0 ; i < k ; i ++ ) { var bitAtIndex = s [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ; if ( ( checker & ( 1 << bitAtIndex ) ) > 0 ) { return false ; } checker = checker | ( 1 << bitAtIndex ) ; } for ( var i = k ; i < s . length ; i ++ ) if ( s [ i - k ] != s [ i ] ) return false ; return true ; } var str = " " ; var K = 4 ; if ( isKAlternating ( str , K ) ) document . write ( " " ) ; else document . write ( " " ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
let MAX = 100000 ; function findFactors ( N ) { let temp = Math . floor ( Math . sqrt ( N ) ) ; let factor = new Array ( MAX ) ; for ( let i = 0 ; i < MAX ; i ++ ) { factor [ i ] = 1 ; } let i , j , k ; let len1 = 1 ; while ( temp % 2 == 0 ) { factor [ len1 ++ ] = 2 ; factor [ len1 ++ ] = 2 ; temp = Math . floor ( temp / 2 ) ; } for ( j = 3 ; j < Math . sqrt ( temp ) ; j += 2 ) { while ( temp % j == 0 ) { factor [ len1 ++ ] = j ; factor [ len1 ++ ] = j ; temp = Math . floor ( temp / j ) ; } } if ( temp > 2 ) { factor [ len1 ++ ] = temp ; factor [ len1 ++ ] = temp ; } let M = new Array ( len1 ) ; for ( let i = 0 ; i < len1 ; i ++ ) { M [ i ] = new Array ( MAX ) ; for ( let j = 0 ; j < MAX ; j ++ ) { M [ i ] [ j ] = 0 ; } } let tpc = 0 , tpr = 0 ; M [ 0 ] [ 0 ] = 1 ; j = 1 ; while ( j < len1 ) { if ( factor [ j ] != factor [ j - 1 ] ) { tpr ++ ; M [ tpr ] [ 0 ] = factor [ j ] ; j ++ ; tpc = 1 ; } else { M [ tpr ] [ tpc ] = M [ tpr ] [ tpc - 1 ] * factor [ j ] ; j ++ ; tpc ++ ; } } let arr1 = new Array ( MAX ) ; let arr2 = new Array ( MAX ) ; for ( let i = 0 ; i < MAX ; i ++ ) { arr1 [ i ] = 0 ; arr2 [ i ] = 0 ; } let l1 , l2 ; l1 = l2 = 1 ; arr1 [ 0 ] = arr2 [ 0 ] = 1 ; for ( i = 1 ; i < tpr + 1 ; i ++ ) { for ( j = 0 ; M [ i ] [ j ] != 0 ; j ++ ) { for ( k = 0 ; k < l1 ; k ++ ) { arr2 [ l2 ++ ] = arr1 [ k ] * M [ i ] [ j ] ; } } for ( j = l1 ; j < l2 ; j ++ ) { arr1 [ j ] = arr2 [ j ] ; } l1 = l2 ; } for ( i = 0 ; i < l2 ; i ++ ) { document . write ( arr2 [ i ] + " " ) ; } } let N = 900 ; findFactors ( N ) ;

Index/key variables: i, j, k, tpc, tpr
Accumulator variables: i, j, k, l2, len1, tpc, tpr
Iterator variables: i, j, k
Javascript program:
let matrix = new Array ( ) ; for ( let i = 0 ; i < 100 ; i ++ ) { let temp = new Array ( ) ; for ( let j = 0 ; j < 100 ; j ++ ) { temp . push ( [ ] ) } matrix . push ( temp ) } function printRequiredMatrix ( n ) { if ( n == 1 ) { document . write ( " " + " " ) ; } else if ( n % 2 != 0 ) { document . write ( " " + " " ) ; } else { for ( let i = 0 ; i < n ; i ++ ) { matrix [ i ] [ i ] = n ; } let u = n - 1 ; for ( let i = 0 ; i < n - 1 ; i ++ ) { matrix [ i ] [ u ] = i + 1 ; for ( let j = 1 ; j < n / 2 ; j ++ ) { let a = ( i + j ) % ( n - 1 ) ; let b = ( i - j + n - 1 ) % ( n - 1 ) ; if ( a < b ) { let temp = a ; a = b ; b = temp } matrix [ b ] [ a ] = i + 1 ; } } for ( let i = 0 ; i < n ; i ++ ) for ( let j = 0 ; j < i ; j ++ ) matrix [ i ] [ j ] = matrix [ j ] [ i ] + n ; for ( let i = 0 ; i < n ; i ++ ) { for ( let j = 0 ; j < n ; j ++ ) document . write ( matrix [ i ] [ j ] + " " ) ; document . write ( " " ) ; } } document . write ( " " ) ; } let n = 1 ; printRequiredMatrix ( n ) ; n = 3 ; printRequiredMatrix ( n ) ; n = 6 ; printRequiredMatrix ( n ) ;

Index/key variables: a, b, i, j, u
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
function countSubstring ( S , n ) { var ans = 0 ; var i = 0 ; while ( i < n ) { var cnt0 = 0 , cnt1 = 0 ; if ( S . charAt ( i ) == ' ' ) { while ( i < n && S . charAt ( i ) == ' ' ) { cnt0 ++ ; i ++ ; } var j = i ; while ( j < n && S . charAt ( j ) == ' ' ) { cnt1 ++ ; j ++ ; } } else { while ( i < n && S . charAt ( i ) == ' ' ) { cnt1 ++ ; i ++ ; } var j = i ; while ( j < n && S . charAt ( j ) == ' ' ) { cnt0 ++ ; j ++ ; } } ans += Math . min ( cnt0 , cnt1 ) ; } return ans ; } var S = " " ; var n = S . length ; document . write ( countSubstring ( S , n ) ) ;

Accumulator variables: ans, cnt0, cnt1, i, j
Javascript program:
function findNumbers ( n ) { let i = 1 ; while ( i <= n ) { document . write ( ( 3 * i * ( i - 1 ) + 1 ) + " " ) ; i ++ ; } } let n = 4 ; findNumbers ( n ) ;

Accumulator variables: i
Javascript program:
function decToOctal ( n ) { var octalNum = Array ( 100 ) . fill ( 0 ) ; var i = 0 ; while ( n != 0 ) { octalNum [ i ] = n % 8 ; n = parseInt ( n / 8 ) ; i ++ ; } for ( var j = i - 1 ; j >= 0 ; j -- ) document . write ( octalNum [ j ] ) ; document . write ( " " ) ; } function nDigitPerfectSquares ( n ) { var decimal = Math . pow ( Math . ceil ( Math . sqrt ( Math . pow ( 8 , n ) ) ) - 1 , 2 ) ; decToOctal ( decimal ) ; } var n = 2 ; nDigitPerfectSquares ( n ) ;

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: j
Javascript program:
function reverseStr ( str , l , h ) { var n = h - l ; for ( var i = 0 ; i < n / 2 ; i ++ ) { [ str [ i + l ] , str [ n - i - 1 + l ] ] = [ str [ n - i - 1 + l ] , str [ i + l ] ] ; } return str ; } function reverseString ( s , A , n ) { s = reverseStr ( s , 0 , A [ 0 ] ) ; for ( var i = 1 ; i < n ; i ++ ) s = reverseStr ( s , A [ i - 1 ] , A [ i ] ) ; s = reverseStr ( s , A [ n - 1 ] , s . length ) ; return s ; } var s = " " ; var A = [ 2 , 4 , 6 ] ; var n = A . length ; s = reverseString ( s . split ( ' ' ) , A , n ) ; document . write ( s . join ( ' ' ) ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function Formatted ( s ) { let k = [ ] ; let i = 0 ; while ( i < s . length ) { if ( s [ i ] == ' ' || s [ i ] == ' ' ) { k . push ( s [ i ] ) ; i += 1 ; } else { let st = 0 ; while ( s [ i ] != ' ' && s [ i ] != ' ' ) { st = s [ i ] ; i = i + 1 ; } k . push ( st ) ; } } let depth = 0 , flag = 1 ; let open = 0 , close = 0 ; for ( let i2 = 0 ; i2 < k . length ; i2 ++ ) { if ( k [ i2 ] == ' ' ) { depth += 1 ; open += 1 ; } else if ( k [ i2 ] == ' ' ) { depth -= 1 ; close += 1 ; } else { if ( k [ i2 ] - ' ' != depth ) { flag = 0 ; break ; } } } if ( open != close ) flag = 0 ; return ( flag == 1 ) ? true : false ; } let s = " " ; let k = Formatted ( s ) ; if ( k == true ) document . write ( " " ) ; else document . write ( " " ) ;

Index/key variables: i, i2
Accumulator variables: close, depth, i, i2, open
Iterator variables: i2
Javascript program:
function maxSubStr ( str , n ) { var count0 = 0 , count1 = 0 ; var cnt = 0 ; for ( var i = 0 ; i < n ; i ++ ) { if ( str [ i ] == ' ' ) { count0 ++ ; } else { count1 ++ ; } if ( count0 == count1 ) { cnt ++ ; } } if ( cnt == 0 ) { return - 1 ; } return cnt ; } var str = " " ; var n = str . length ; document . write ( maxSubStr ( str , n ) ) ;

Index/key variables: i
Accumulator variables: cnt, count0, count1, i
Iterator variables: i
Javascript program:
function getString ( x ) { return x } function solve ( s1 , s2 ) { var a = getString ( s1 [ 0 ] ) , b = getString ( s2 [ 0 ] ) ; for ( var i = 1 ; i < s1 . length ; i ++ ) if ( s1 [ i ] != s1 [ i - 1 ] ) { a += getString ( s1 [ i ] ) ; } for ( var i = 1 ; i < s2 . length ; i ++ ) if ( s2 [ i ] != s2 [ i - 1 ] ) { b += getString ( s2 [ i ] ) ; } if ( a == b ) return true ; return false ; } var s1 = " " , s2 = " " ; if ( solve ( s1 , s2 ) ) document . write ( " " ) ; else document . write ( " " ) ;

Index/key variables: i
Accumulator variables: a, b, i
Iterator variables: i
Javascript program:
var x = 26 ; var mod = 3001 ; function CntSubstr ( s , l ) { var hash = 0 ; for ( var i = 0 ; i < l ; i ++ ) { hash = ( hash * x + ( s [ i ] . charCodeAt ( 0 ) - 97 ) ) % mod ; } var pow_l = 1 ; for ( var i = 0 ; i < l - 1 ; i ++ ) pow_l = ( pow_l * x ) % mod ; var result = new Set ( ) ; result . add ( hash ) ; for ( var i = l ; i < s . length ; i ++ ) { hash = ( ( hash - pow_l * ( s [ i - l ] . charCodeAt ( 0 ) - 97 ) + 2 * mod ) * x + ( s [ i ] . charCodeAt ( 0 ) - 97 ) ) % mod ; result . add ( hash ) ; } document . write ( result . size ) ; } var s = " " ; var l = 2 ; CntSubstr ( s , l ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function endsWith ( str , pat ) { let patLen = pat . length ; let strLen = str . length ; if ( patLen > strLen ) return false ; patLen -- ; strLen -- ; while ( patLen >= 0 ) { if ( pat [ patLen ] != str [ strLen ] ) return false ; patLen -- ; strLen -- ; } return true ; } function countOfStrings ( pat , n , sArr ) { let count = 0 ; for ( let i = 0 ; i < n ; i ++ ) { if ( endsWith ( sArr [ i ] , pat ) ) count ++ ; } return count ; } let pat = " " ; let n = 4 ; let sArr = [ " " , " " , " " , " " ] ; document . write ( countOfStrings ( pat , n , sArr ) ) ;

Index/key variables: i, patLen, strLen
Accumulator variables: count, i, patLen, strLen
Iterator variables: i
Javascript program:
function getEndingIndex ( str , n , i ) { i ++ ; while ( i < n ) { let curr = str [ i ] ; let prev = str [ i - 1 ] ; if ( ( curr == ' ' && prev == ' ' ) || ( curr . charCodeAt ( 0 ) - prev . charCodeAt ( 0 ) == 1 ) ) i ++ ; else break ; } return i - 1 ; } function largestSubStr ( str , n ) { let len = 0 ; let i = 0 ; while ( i < n ) { let end = getEndingIndex ( str , n , i ) ; len = Math . max ( end - i + 1 , len ) ; i = end + 1 ; } return len ; } let str = " " ; let n = str . length ; document . write ( largestSubStr ( str , n ) ) ;

Index/key variables: i
Accumulator variables: i
Javascript program:
function getSum ( n , d ) { if ( n < d ) return 0 ; while ( n % 10 != d ) n -- ; k = parseInt ( n / 10 ) ; return ( k + 1 ) * d + ( k * 10 + 10 * k * k ) / 2 ; } let n = 30 ; let d = 3 ; document . write ( getSum ( n , d ) ) ;

Accumulator variables: n
Javascript program:
function getFrequencyMap ( arr ) { var hashMap = { } ; for ( var i = 0 ; i < arr . length ; i ++ ) { if ( hashMap . hasOwnProperty ( arr [ i ] ) ) { hashMap [ arr [ i ] ] = hashMap [ arr [ i ] ] + 1 ; } else { hashMap [ arr [ i ] ] = 1 ; } } return hashMap ; } function hasDigit ( hashMap , digit ) { if ( hashMap . hasOwnProperty ( digit ) && hashMap [ digit ] > 0 ) { hashMap [ digit ] = hashMap [ digit ] - 1 ; return true ; } return false ; } function getMaxTime ( arr ) { var hashMap = getFrequencyMap ( arr ) ; var i ; var flag ; var time = " " ; flag = false ; for ( i = 2 ; i >= 0 ; i -- ) { if ( hasDigit ( hashMap , i ) ) { flag = true ; time += i ; break ; } } if ( ! flag ) { return " " ; } flag = false ; if ( time [ 0 ] === " " ) { for ( i = 3 ; i >= 0 ; i -- ) { if ( hasDigit ( hashMap , i ) ) { flag = true ; time += i ; break ; } } } else { for ( i = 9 ; i >= 0 ; i -- ) { if ( hasDigit ( hashMap , i ) ) { flag = true ; time += i ; break ; } } } if ( ! flag ) { return " " ; } time += " " ; flag = false ; for ( i = 5 ; i >= 0 ; i -- ) { if ( hasDigit ( hashMap , i ) ) { flag = true ; time += i ; break ; } } if ( ! flag ) { return " " ; } flag = false ; for ( i = 9 ; i >= 0 ; i -- ) { if ( hasDigit ( hashMap , i ) ) { flag = true ; time += i ; break ; } } if ( ! flag ) { return " " ; } return time ; } var arr = [ 0 , 0 , 0 , 9 ] ; document . write ( getMaxTime ( arr ) ) ;

Index/key variables: digit, i
Accumulator variables: i, time
Iterator variables: i
Boolean variables: flag