dhyuti-n/xlcost-variable-roles huggingface dataset:
Javascript program:
let mod = 1000000007 ; function noOfBinaryStrings ( N , k ) { let dp = new Array ( 100002 ) ; for ( let i = 1 ; i <= k - 1 ; i ++ ) { dp [ i ] = 1 ; } dp [ k ] = 2 ; for ( let i = k + 1 ; i <= N ; i ++ ) { dp [ i ] = ( dp [ i - 1 ] + dp [ i - k ] ) % mod ; } return dp [ N ] ; } let N = 4 ; let K = 2 ; document . write ( noOfBinaryStrings ( N , K ) ) ;

Index/key variables: N, i, k
Accumulator variables: i
Iterator variables: i
Javascript program:
function findWaysToPair ( p ) { var dp = Array ( p + 1 ) ; dp [ 1 ] = 1 ; dp [ 2 ] = 2 ; for ( var i = 3 ; i <= p ; i ++ ) { dp [ i ] = dp [ i - 1 ] + ( i - 1 ) * dp [ i - 2 ] ; } return dp [ p ] ; } var p = 3 ; document . write ( findWaysToPair ( p ) ) ;

Index/key variables: i, p
Accumulator variables: i
Iterator variables: i
Javascript program:
function factors ( n ) { var v = [ ] ; v . push ( 1 ) ; for ( var i = 2 ; i <= Math . sqrt ( n ) ; i ++ ) { if ( n % i == 0 ) { v . push ( i ) ; if ( n / i != i ) { v . push ( n / i ) ; } } } return v ; } function checkAbundant ( n ) { var v = [ ] ; var sum = 0 ; v = factors ( n ) ; for ( var i = 0 ; i < v . length ; i ++ ) { sum += v [ i ] ; } if ( sum > n ) return true ; else return false ; } function checkSemiPerfect ( n ) { var v = [ ] ; v = factors ( n ) ; v . sort ( ) var r = v . length ; var subset = Array . from ( Array ( r + 1 ) , ( ) => Array ( n + 1 ) ) ; for ( var i = 0 ; i <= r ; i ++ ) subset [ i ] [ 0 ] = true ; for ( var i = 1 ; i <= n ; i ++ ) subset [ 0 ] [ i ] = false ; for ( var i = 1 ; i <= r ; i ++ ) { for ( var j = 1 ; j <= n ; j ++ ) { if ( j < v [ i - 1 ] ) subset [ i ] [ j ] = subset [ i - 1 ] [ j ] ; else { subset [ i ] [ j ] = subset [ i - 1 ] [ j ] || subset [ i - 1 ] [ j - v [ i - 1 ] ] ; } } } if ( ( subset [ r ] [ n ] ) == 0 ) return false ; else return true ; } function checkweird ( n ) { if ( checkAbundant ( n ) == true && checkSemiPerfect ( n ) == false ) return true ; else return false ; } var n = 70 ; if ( checkweird ( n ) ) document . write ( " " ) ; else document . write ( " " ) ;

Index/key variables: i, j, n, r
Accumulator variables: i, j, sum
Iterator variables: i, j
Javascript program:
function maxSubArraySumRepeated ( a , n , k ) { let max_so_far = 0 ; let INT_MIN , max_ending_here = 0 ; for ( let i = 0 ; i < n * k ; i ++ ) { max_ending_here = max_ending_here + a [ i % n ] ; if ( max_so_far < max_ending_here ) max_so_far = max_ending_here ; if ( max_ending_here < 0 ) max_ending_here = 0 ; } return max_so_far ; } let a = [ 10 , 20 , - 30 , - 1 ] ; let n = a . length ; let k = 3 ; document . write ( " " + maxSubArraySumRepeated ( a , n , k ) ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function longOddEvenIncSeq ( arr , n ) { let lioes = [ ] ; let maxLen = 0 ; for ( let i = 0 ; i < n ; i ++ ) lioes [ i ] = 1 ; for ( let i = 1 ; i < n ; i ++ ) for ( let j = 0 ; j < i ; j ++ ) if ( arr [ i ] > arr [ j ] && ( arr [ i ] + arr [ j ] ) % 2 != 0 && lioes [ i ] < lioes [ j ] + 1 ) lioes [ i ] = lioes [ j ] + 1 ; for ( let i = 0 ; i < n ; i ++ ) if ( maxLen < lioes [ i ] ) maxLen = lioes [ i ] ; return maxLen ; } let arr = [ 1 , 12 , 2 , 22 , 5 , 30 , 31 , 14 , 17 , 11 ] ; let n = 10 ; document . write ( " " + " " + longOddEvenIncSeq ( arr , n ) ) ;

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
function isOperator ( op ) { return ( op == ' ' op == ' ' ) ; } function printMinAndMaxValueOfExp ( exp ) { let num = [ ] ; let opr = [ ] ; let tmp = " " ; for ( let i = 0 ; i < exp . length ; i ++ ) { if ( isOperator ( exp [ i ] ) ) { opr . push ( exp [ i ] ) ; num . push ( parseInt ( tmp ) ) ; tmp = " " ; } else { tmp += exp [ i ] ; } } num . push ( parseInt ( tmp ) ) ; let len = num . length ; let minVal = new Array ( len ) ; let maxVal = new Array ( len ) ; for ( let i = 0 ; i < len ; i ++ ) { minVal [ i ] = new Array ( len ) ; maxVal [ i ] = new Array ( len ) ; for ( let j = 0 ; j < len ; j ++ ) { minVal [ i ] [ j ] = Number . MAX_VALUE ; maxVal [ i ] [ j ] = 0 ; if ( i == j ) minVal [ i ] [ j ] = maxVal [ i ] [ j ] = num [ i ] ; } } for ( let L = 2 ; L <= len ; L ++ ) { for ( let i = 0 ; i < len - L + 1 ; i ++ ) { let j = i + L - 1 ; for ( let k = i ; k < j ; k ++ ) { let minTmp = 0 , maxTmp = 0 ; if ( opr [ k ] == ' ' ) { minTmp = minVal [ i ] [ k ] + minVal [ k + 1 ] [ j ] ; maxTmp = maxVal [ i ] [ k ] + maxVal [ k + 1 ] [ j ] ; } else if ( opr [ k ] == ' ' ) { minTmp = minVal [ i ] [ k ] * minVal [ k + 1 ] [ j ] ; maxTmp = maxVal [ i ] [ k ] * maxVal [ k + 1 ] [ j ] ; } if ( minTmp < minVal [ i ] [ j ] ) minVal [ i ] [ j ] = minTmp ; if ( maxTmp > maxVal [ i ] [ j ] ) maxVal [ i ] [ j ] = maxTmp ; } } } document . write ( " " + minVal [ 0 ] [ len - 1 ] + " " + maxVal [ 0 ] [ len - 1 ] ) ; } let expression = " " ; printMinAndMaxValueOfExp ( expression ) ;

Index/key variables: i, j, k
Accumulator variables: L, i, j, k, tmp
Iterator variables: L, i, j, k
Javascript program:
function MatrixChainOrder ( p , i , j ) { if ( i == j ) return 0 ; var min = Number . MAX_VALUE ; var k = 0 ; for ( k = i ; k < j ; k ++ ) { var count = MatrixChainOrder ( p , i , k ) + MatrixChainOrder ( p , k + 1 , j ) + p [ i - 1 ] * p [ k ] * p [ j ] ; if ( count < min ) min = count ; } return min ; } var arr = [ 1 , 2 , 3 , 4 , 3 ] ; var n = arr . length ; document . write ( " " + MatrixChainOrder ( arr , 1 , n - 1 ) ) ;

Index/key variables: j, k
Accumulator variables: k
Iterator variables: k
Javascript program:
let m = 1000000007 ; function solve ( n ) { let s = 0 ; for ( let l = 1 ; l <= n ; ) { let r = ( n / Math . floor ( n / l ) ) ; let x = Math . floor ( ( ( r % m ) * ( ( r + 1 ) % m ) ) / 2 ) % m ; let y = Math . floor ( ( ( l % m ) * ( ( l - 1 ) % m ) ) / 2 ) % m ; let p = ( Math . floor ( n / l ) % m ) ; s = ( s + ( ( ( x - y ) % m ) * p ) % m + m ) % m ; s %= m ; l = r + 1 ; } document . write ( ( s + m ) % m ) ; } let n = 12 ; solve ( n ) ;

Iterator variables: l
Javascript program:
function findDistinctSums ( n ) { s = new Set ( ) ; for ( var i = 1 ; i <= n ; i ++ ) { for ( var j = i ; j <= n ; j ++ ) { s . add ( i + j ) ; } } return s . size ; } var N = 3 ; document . write ( findDistinctSums ( N ) ) ;

Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
function zArray ( arr ) { let n = arr . length ; let z = new Array ( n ) ; let r = 0 , l = 0 ; for ( let k = 1 ; k < n ; k ++ ) { if ( k > r ) { r = l = k ; while ( r < n && arr [ r ] == arr [ r - l ] ) r ++ ; z [ k ] = r - l ; r -- ; } else { let k1 = k - l ; if ( z [ k1 ] < r - k + 1 ) z [ k ] = z [ k1 ] ; else { l = k ; while ( r < n && arr [ r ] == arr [ r - l ] ) r ++ ; z [ k ] = r - l ; r -- ; } } } return z ; } function mergeArray ( A , B ) { let n = A . length ; let m = B . length ; let z = new Array ( ) ; let c = new Array ( n + m + 1 ) ; for ( let i = 0 ; i < m ; i ++ ) c [ i ] = B [ i ] ; c [ m ] = Number . MAX_SAFE_INTEGER ; for ( let i = 0 ; i < n ; i ++ ) c [ m + i + 1 ] = A [ i ] ; z = zArray ( c ) ; return z ; } function findZArray ( A , B , n ) { let flag = 0 ; let z = [ ] ; z = mergeArray ( A , B ) ; for ( let i = 0 ; i < z . length ; i ++ ) { if ( z [ i ] == n ) { document . write ( ( i - n - 1 ) + " " ) ; flag = 1 ; } } if ( flag == 0 ) { document . write ( " " ) ; } } let A = [ 1 , 2 , 3 , 2 , 3 , 2 ] ; let B = [ 2 , 3 ] ; let n = B . length ; findZArray ( A , B , n ) ;

Index/key variables: i, k, k1, m, r
Accumulator variables: i, k, r
Iterator variables: i, k
Javascript program:
function getCount ( a , b ) { if ( b . length % a . length != 0 ) return - 1 ; var count = parseInt ( b . length / a . length ) ; var str = " " ; for ( i = 0 ; i < count ; i ++ ) { str = str + a ; } if ( str == ( b ) ) return count ; return - 1 ; } var a = " " ; var b = " " ; document . write ( getCount ( a , b ) ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function check ( S1 , S2 ) { var n1 = S1 . length ; var n2 = S2 . length ; var mp = { } ; for ( var i = 0 ; i < n1 ; i ++ ) { if ( mp . hasOwnProperty ( S1 [ i ] ) ) { mp [ S1 [ i ] ] = mp [ S1 [ i ] ] + 1 ; } else { mp [ S1 [ i ] ] = 1 ; } } for ( var i = 0 ; i < n2 ; i ++ ) { if ( mp . hasOwnProperty ( S2 [ i ] ) ) { mp [ S2 [ i ] ] = mp [ S2 [ i ] ] - 1 ; } else if ( mp . hasOwnProperty ( String . fromCharCode ( S2 [ i ] . charCodeAt ( 0 ) - 1 ) ) && mp . hasOwnProperty ( String . fromCharCode ( S2 [ i ] . charCodeAt ( 0 ) - 2 ) ) ) { mp [ String . fromCharCode ( S2 [ i ] . charCodeAt ( 0 ) - 1 ) ] = mp [ String . fromCharCode ( S2 [ i ] . charCodeAt ( 0 ) - 1 ) ] - 1 ; mp [ String . fromCharCode ( S2 [ i ] . charCodeAt ( 0 ) - 2 ) ] = mp [ String . fromCharCode ( S2 [ i ] . charCodeAt ( 0 ) - 2 ) ] - 1 ; } else { return false ; } } return true ; } var S1 = " " ; var S2 = " " ; if ( check ( S1 , S2 ) ) document . write ( " " ) ; else document . write ( " " ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function countPattern ( str ) { let len = str . length ; let oneSeen = false ; for ( let i = 0 ; i < len ; i ++ ) { let getChar = str [ i ] ; if ( getChar == ' ' && oneSeen == true ) { if ( str [ i - 1 ] == ' ' ) count ++ ; } if ( getChar == ' ' && oneSeen == false ) oneSeen = true ; if ( getChar != ' ' && str [ i ] != ' ' ) oneSeen = false ; } return count ; } let str = " " ; document . write ( countPattern ( str ) ) ;

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Boolean variables: oneSeen
Javascript program:
function checkIfPossible ( N , arr , T ) { let freqS = new Array ( 256 ) . fill ( 0 ) ; let freqT = new Array ( 256 ) . fill ( 0 ) ; for ( let ch of T ) { freqT [ ch . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] ++ ; } for ( let i = 0 ; i < N ; i ++ ) { for ( let ch of arr [ i ] ) { freqS [ ch . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] ++ ; } } for ( let i = 0 ; i < 256 ; i ++ ) { if ( freqT [ i ] == 0 && freqS [ i ] != 0 ) { return " " ; } else if ( freqS [ i ] == 0 && freqT [ i ] != 0 ) { return " " ; } else if ( freqT [ i ] != 0 && freqS [ i ] != ( freqT [ i ] * N ) ) { return " " ; } } return " " ; } let arr = [ " " , " " , " " ] ; let T = " " ; let N = arr . length ; document . write ( checkIfPossible ( N , arr , T ) ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: ch, i
Javascript program:
function groupsOfOnes ( S , N ) { let count = 0 ; var st = [ ] ; for ( let i = 0 ; i < N ; i ++ ) { if ( S [ i ] == ' ' ) st . push ( 1 ) ; else { if ( st . length != 0 ) { count ++ ; while ( st . length != 0 ) { st . pop ( ) ; } } } } if ( st . length != 0 ) count ++ ; return count ; } var S = " " ; let N = S . length ; document . write ( groupsOfOnes ( S , N ) ) ;

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Javascript program:
function generatePalindrome ( S ) { let Hash = new Map ( ) ; for ( let ch = 0 ; ch < S . length ; ch ++ ) { if ( ! Hash . has ( S [ ch ] ) ) Hash . set ( S [ ch ] , 1 ) ; else { Hash . set ( S [ ch ] , Hash . get ( S [ ch ] ) + 1 ) } } let st = new Set ( ) ; for ( let i = ' ' . charCodeAt ( 0 ) ; i <= ' ' . charCodeAt ( 0 ) ; i ++ ) { if ( Hash . get ( String . fromCharCode ( i ) ) == 2 ) { for ( let j = ' ' . charCodeAt ( 0 ) ; j <= ' ' . charCodeAt ( 0 ) ; j ++ ) { let s = " " ; if ( Hash . get ( String . fromCharCode ( j ) ) && i != j ) { s += String . fromCharCode ( i ) ; s += String . fromCharCode ( j ) ; s += String . fromCharCode ( i ) ; st . add ( s ) ; } } } if ( Hash . get ( String . fromCharCode ( i ) ) >= 3 ) { for ( let j = ' ' . charCodeAt ( 0 ) ; j <= ' ' . charCodeAt ( 0 ) ; j ++ ) { let s = " " ; if ( Hash . get ( String . fromCharCode ( j ) ) ) { s += String . fromCharCode ( i ) ; s += String . fromCharCode ( j ) ; s += String . fromCharCode ( i ) ; st . add ( s ) ; } } } } for ( let item of st . values ( ) ) { document . write ( item + " " ) } } let S = " " ; generatePalindrome ( S ) ;

Index/key variables: ch
Accumulator variables: ch, i, j, s
Iterator variables: ch, i, item, j
Javascript program:
function countOccurrences ( S , X , Y ) { let count = 0 ; let N = S . length , A = X . length ; let B = Y . length ; for ( let i = 0 ; i < N ; i ++ ) { if ( S . substr ( i , B ) == Y ) count ++ ; if ( S . substr ( i , A ) == X ) document . write ( count , " " ) ; } } let S = " " , X = " " , Y = " " ; countOccurrences ( S , X , Y ) ;

Accumulator variables: count, i
Iterator variables: i
Javascript program:
function DFA ( str , N ) { if ( N <= 1 ) { document . write ( " " ) ; return ; } let count = 0 ; if ( str [ 0 ] == ' ' ) { count ++ ; for ( let i = 1 ; i < N ; i ++ ) { if ( str [ i ] == ' ' str [ i ] == ' ' ) count ++ ; else break ; } } else { document . write ( " " ) ; return ; } if ( count == N ) document . write ( " " ) ; else document . write ( " " ) ; } let str = " " ; let N = str . length ; DFA ( str , N ) ;

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Javascript program:
function minMaxDigits ( str , N ) { let arr = [ ] ; for ( let i = 0 ; i < N ; i ++ ) arr [ i ] = ( str [ i ] - ' ' ) % 3 ; let zero = 0 , one = 0 , two = 0 ; for ( let i = 0 ; i < N ; i ++ ) { if ( arr [ i ] == 0 ) zero ++ ; if ( arr [ i ] == 1 ) one ++ ; if ( arr [ i ] == 2 ) two ++ ; } let sum = 0 ; for ( let i = 0 ; i < N ; i ++ ) { sum = ( sum + arr [ i ] ) % 3 ; } if ( sum == 0 ) { document . write ( 0 + " " ) ; } if ( sum == 1 ) { if ( ( one != 0 ) && ( N > 1 ) ) document . write ( 1 + " " ) ; else if ( two > 1 && N > 2 ) document . write ( 2 + " " ) ; else document . write ( - 1 + " " ) ; } if ( sum == 2 ) { if ( two != 0 && N > 1 ) document . write ( 1 + " " ) ; else if ( one > 1 && N > 2 ) document . write ( 2 + " " ) ; else document . write ( - 1 + " " ) ; } if ( zero > 0 ) document . write ( N - 1 + " " ) ; else if ( one > 0 && two > 0 ) document . write ( N - 2 + " " ) ; else if ( one > 2 two > 2 ) document . write ( N - 3 + " " ) ; else document . write ( - 1 + " " ) ; } let str = " " ; let N = str . length ; minMaxDigits ( str , N ) ;

Index/key variables: i
Accumulator variables: i, one, two, zero
Iterator variables: i
Javascript program:
function findMinimumChanges ( N , K , S ) { var ans = 0 ; for ( var i = 0 ; i < parseInt ( ( K + 1 ) / 2 ) ; i ++ ) { var mp = new Map ( ) ; for ( var j = i ; j < N ; j += K ) { if ( mp . has ( S [ j ] ) ) { mp . set ( S [ j ] , mp . get ( S [ j ] ) + 1 ) ; } else { mp . set ( S [ j ] , 1 ) ; } } for ( var j = N - i - 1 ; j >= 0 ; j -= K ) { if ( ( K & 1 ) && i == parseInt ( K / 2 ) ) break ; if ( mp . has ( S [ j ] ) ) { mp . set ( S [ j ] , mp . get ( S [ j ] ) + 1 ) ; } else { mp . set ( S [ j ] , 1 ) ; } } var curr_max = - 1000000000 ; mp . forEach ( ( value , key ) => { curr_max = Math . max ( curr_max , value ) ; } ) ; if ( K & 1 && i == parseInt ( K / 2 ) ) ans += ( parseInt ( N / K ) - curr_max ) ; else ans += ( parseInt ( N / K ) * 2 - curr_max ) ; } return ans ; } var S = " " ; var N = S . length ; var K = 3 ; document . write ( findMinimumChanges ( N , K , S ) ) ;

Index/key variables: j
Accumulator variables: ans, i, j
Iterator variables: i, j
Javascript program:
function checkString ( s , K ) { var n = s . length ; var mp = new Map ( ) ; for ( var i = 0 ; i < n ; i ++ ) { if ( mp . has ( s [ i ] ) ) { mp . set ( s [ i ] , mp . get ( s [ i ] ) + 1 ) ; } else mp . set ( s [ i ] , 1 ) ; } var cnt = 0 , f = 0 ; var st = new Set ( ) ; for ( var i = 0 ; i < n ; i ++ ) { st . add ( s [ i ] ) ; if ( st . size > K ) { f = 1 ; break ; } if ( mp . get ( s [ i ] ) == i ) st . delete ( s [ i ] ) ; } return ( f == 1 ? " " : " " ) ; } var s = " " ; var k = 2 ; document . write ( checkString ( s , k ) ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function distinct ( S , M , n ) { let count = 0 ; for ( let i = 0 ; i < n ; i ++ ) { let set1 = new Set ( ) ; for ( let j = 0 ; j < S [ i ] . length ; j ++ ) { if ( ! set1 . has ( S [ i ] [ j ] ) ) set1 . add ( S [ i ] [ j ] ) ; } let c = set1 . size ; if ( c <= M ) count += 1 ; } document . write ( count ) ; } let S = [ " " , " " , " " ] ; let M = 7 ; let n = S . length ; distinct ( S , M , n ) ;

Index/key variables: i, j
Accumulator variables: count, i, j
Iterator variables: i, j
Javascript program:
function removeOddFrequencyCharacters ( s ) { let m = new Map ( ) ; for ( let i = 0 ; i < s . length ; i ++ ) { let p = s [ i ] ; let count = m . get ( p ) ; if ( count == null ) { count = 0 ; m . set ( p , 1 ) ; } else m . set ( p , count + 1 ) ; } let new_string = " " ; for ( let i = 0 ; i < s . length ; i ++ ) { if ( ( m . get ( s [ i ] ) & 1 ) == 1 ) continue ; new_string += s [ i ] ; } return new_string ; } let str = " " ; str = removeOddFrequencyCharacters ( str ) ; document . write ( str ) ;

Index/key variables: i
Accumulator variables: i, new_string
Iterator variables: i
Javascript program:
var i ; function productAtKthLevel ( tree , k , level ) { if ( tree [ i ++ ] == ' ' ) { if ( tree [ i ] == ' ' ) return 1 ; var product = 1 ; if ( level == k ) product = tree [ i ] - ' ' ; ++ i ; var leftproduct = productAtKthLevel ( tree , k , level + 1 ) ; ++ i ; var rightproduct = productAtKthLevel ( tree , k , level + 1 ) ; ++ i ; return product * leftproduct * rightproduct ; } return int . MinValue ; } var tree = " " ; var k = 2 ; i = 0 ; document . write ( productAtKthLevel ( tree , k , 0 ) ) ;

Index/key variables: i
Accumulator variables: i
Javascript program:
function findMostOccurringChar ( str ) { var hash = Array ( 26 ) . fill ( 0 ) ; for ( var i = 0 ; i < str . length ; i ++ ) { for ( var j = 0 ; j < str [ i ] . length ; j ++ ) { hash [ str [ i ] [ j ] ] ++ ; } } var max = 0 ; for ( var i = 0 ; i < 26 ; i ++ ) { max = hash [ i ] > hash [ max ] ? i : max ; } document . write ( String . fromCharCode ( max + 97 ) ) ; } var str = [ ] ; str . push ( " " ) ; str . push ( " " ) ; str . push ( " " ) ; str . push ( " " ) ; findMostOccurringChar ( str ) ;

Index/key variables: i, j, max
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
function isPalindrome ( num ) { var s = num . toString ( ) ; var low = 0 ; var high = s . length - 1 ; while ( low < high ) { if ( s [ low ] != s [ high ] ) return false ; low ++ ; high -- ; } return true ; } var n = 123.321 ; if ( isPalindrome ( n ) ) document . write ( " " ) ; else document . write ( " " ) ;

Index/key variables: high, low
Accumulator variables: high, low
Javascript program:
const MAX = 26 ; function maxSubStr ( str1 , len1 , str2 , len2 ) { if ( len1 > len2 ) return 0 ; let freq1 = new Array ( MAX ) . fill ( 0 ) ; for ( let i = 0 ; i < len1 ; i ++ ) freq1 [ str1 . charCodeAt ( i ) - ' ' . charCodeAt ( 0 ) ] ++ ; let freq2 = new Array ( MAX ) . fill ( 0 ) ; for ( let i = 0 ; i < len2 ; i ++ ) freq2 [ str2 . charCodeAt ( i ) - ' ' . charCodeAt ( 0 ) ] ++ ; let minPoss = Number . MAX_SAFE_INTEGER ; for ( let i = 0 ; i < MAX ; i ++ ) { if ( freq1 [ i ] == 0 ) continue ; if ( freq1 [ i ] > freq2 [ i ] ) return 0 ; minPoss = Math . min ( minPoss , Math . floor ( freq2 [ i ] / freq1 [ i ] ) ) ; } return minPoss ; } let str1 = " " , str2 = " " ; let len1 = str1 . length ; let len2 = str2 . length ; document . write ( maxSubStr ( str1 , len1 , str2 , len2 ) ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
var uSet = new Set ( ) ; var minCnt = 1000000000 ; function findSubStr ( str , cnt , start ) { if ( start == str . length ) { minCnt = Math . min ( cnt , minCnt ) ; } for ( var len = 1 ; len <= ( str . length - start ) ; len ++ ) { var subStr = str . substring ( start , start + len ) ; if ( uSet . has ( subStr ) ) { findSubStr ( str , cnt + 1 , start + len ) ; } } } function findMinSubStr ( arr , n , str ) { for ( var i = 0 ; i < n ; i ++ ) uSet . add ( arr [ i ] ) ; findSubStr ( str , 0 , 0 ) ; } var str = " " ; var arr = [ " " , " " , " " , " " , " " , " " ] ; var n = arr . length ; findMinSubStr ( arr , n , str ) ; document . write ( minCnt ) ;

Index/key variables: i
Accumulator variables: i, len
Iterator variables: i, len
Javascript program:
function countSubStr ( s , n ) { var c1 = 0 , c2 = 0 ; for ( var i = 0 ; i < n ; i ++ ) { if ( s . substring ( i , i + 5 ) == " " ) c1 ++ ; if ( s . substring ( i , i + 3 ) == " " ) c2 = c2 + c1 ; } return c2 ; } var s = " " ; var n = s . length ; document . write ( countSubStr ( s , n ) ) ;

Accumulator variables: c1, i
Iterator variables: i
Javascript program:
let string = " " ; let lst1 = [ ' ' , ' ' , ' ' ] ; let lst2 = [ ' ' , ' ' , ' ' ] ; let lst = [ ] ; let Dict = { ' ' : ' ' , ' ' : ' ' , ' ' : ' ' } let a = 0 , b = 0 , c = 0 ; if ( string [ 0 ] in lst2 ) { document . write ( 1 + " " ) ; } else { for ( let i = 0 ; i < string . length ; i ++ ) { if ( string [ i ] in lst1 ) { lst . push ( string [ i ] ) ; k = i + 2 ; } else { if ( lst . lengt == 0 && ( string [ i ] in lst2 ) ) { document . write ( ( i + 1 ) + " " ) ; c = 1 ; break ; } else { if ( Dict [ string [ i ] ] == lst [ lst . length - 1 ] ) { lst . pop ( ) ; } else { break ; document . write ( ( i + 1 ) + " " ) ; a = 1 ; } } } } if ( lst . length == 0 && c == 0 ) { document . write ( 0 + " " ) ; b = 1 ; } if ( a == 0 && b == 0 && c == 0 ) { document . write ( k + " " ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
var MAX = 26 ; function encryptStr ( str , n , x ) { x = x % MAX ; var freq = Array ( MAX ) . fill ( 0 ) ; for ( var i = 0 ; i < n ; i ++ ) { freq [ str [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] ++ ; } for ( var i = 0 ; i < n ; i ++ ) { if ( freq [ str [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] % 2 == 0 ) { var pos = ( str [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) + x ) % MAX ; str [ i ] = String . fromCharCode ( pos + ' ' . charCodeAt ( 0 ) ) ; } else { var pos = ( str [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) - x ) ; if ( pos < 0 ) { pos += MAX ; } str [ i ] = String . fromCharCode ( pos + ' ' . charCodeAt ( 0 ) ) ; } } return str . join ( ' ' ) ; } var s = " " ; var n = s . length ; var x = 3 ; document . write ( encryptStr ( s . split ( ' ' ) , n , x ) ) ;

Index/key variables: i
Accumulator variables: i, pos
Iterator variables: i
Javascript program:
function isPossible ( str ) { let freq = new Map ( ) ; let max_freq = 0 ; for ( let j = 0 ; j < ( str . length ) ; j ++ ) { if ( freq . has ( str [ j ] ) ) { freq . set ( str [ j ] , freq . get ( str [ j ] ) + 1 ) ; if ( freq . get ( str [ j ] ) > max_freq ) max_freq = freq . get ( str [ j ] ) ; } else { freq . set ( str [ j ] , 1 ) ; if ( freq . get ( str [ j ] ) > max_freq ) max_freq = freq . get ( str [ j ] ) ; } } if ( max_freq <= ( str . length - max_freq + 1 ) ) return true ; return false ; } let str = " " ; if ( isPossible ( str . split ( ' ' ) ) ) document . write ( " " ) ; else document . write ( " " ) ;

Index/key variables: j
Accumulator variables: j
Iterator variables: j
Javascript program:
function printUncommon ( str1 , str2 ) { var a1 = 0 , a2 = 0 ; for ( var i = 0 ; i < str1 . length ; i ++ ) { var ch = ( str1 [ i ] . charCodeAt ( 0 ) ) - ' ' . charCodeAt ( 0 ) ; a1 = a1 | ( 1 << ch ) ; } for ( var i = 0 ; i < str2 . length ; i ++ ) { var ch = ( str2 [ i ] . charCodeAt ( 0 ) ) - ' ' . charCodeAt ( 0 ) ; a2 = a2 | ( 1 << ch ) ; } var ans = a1 ^ a2 ; var i = 0 ; while ( i < 26 ) { if ( ans % 2 == 1 ) { document . write ( String . fromCharCode ( ' ' . charCodeAt ( 0 ) + i ) ) ; } ans = parseInt ( ans / 2 ) ; i ++ ; } } var str1 = " " ; var str2 = " " ; printUncommon ( str1 , str2 ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function countMinReversals ( expr ) { var len = expr . length ; if ( len % 2 ) return - 1 ; var ans = 0 ; var i ; var open = 0 ; var close = 0 ; for ( i = 0 ; i < len ; i ++ ) { if ( expr [ i ] == ' ' ) open ++ ; else { if ( ! open ) close ++ ; else open -- ; } } ans = ( close / 2 ) + ( open / 2 ) ; close %= 2 ; open %= 2 ; if ( close ) ans += 2 ; return ans ; } var expr = " " ; document . write ( countMinReversals ( expr ) ) ;

Index/key variables: i
Accumulator variables: ans, close, i, open
Iterator variables: i