dhyuti-n/xlcost-variable-roles huggingface dataset:
Javascript program:
function countOperations ( S ) { let n = S . length ; let ans = 0 ; let cnt = 0 ; for ( let i = 0 ; i < n ; i ++ ) { if ( S [ i ] == ' ' ) { cnt ++ ; } else { if ( cnt > 0 ) { cnt -- ; ans ++ ; } } } document . write ( ans ) ; } let S = " " ; countOperations ( S ) ;

Index/key variables: i
Accumulator variables: ans, cnt, i
Iterator variables: i
Javascript program:
function isSumEqual ( A , B , C ) { let L = A . length ; let M = B . length ; let N = A . length ; A . split ( " " ) . reverse ( ) . join ( " " ) ; B . split ( " " ) . reverse ( ) . join ( " " ) ; C . split ( " " ) . reverse ( ) . join ( " " ) ; let rem = 0 ; for ( let i = 0 ; i < Math . max ( L , Math . max ( M , N ) ) ; i ++ ) { let curr = rem ; if ( i < L ) curr += A [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ; if ( i < M ) curr += B [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ; rem = Math . floor ( curr / 10 ) ; curr %= 10 ; if ( i < N && curr != C [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ) { return " " ; } } if ( rem ) return " " ; else return " " ; } let A = " " , B = " " , C = " " ; document . write ( isSumEqual ( A , B , C ) ) ;

Index/key variables: i
Accumulator variables: curr, i
Iterator variables: i
Javascript program:
function MinimumLengthSubstring ( S , N ) { let ans = N ; S = " " + S + " " ; S = S . split ( " " ) for ( let c = ' ' . charCodeAt ( 0 ) ; c <= ' ' . charCodeAt ( 0 ) ; ++ c ) { let prev = 0 ; let max_len = 0 ; S [ 0 ] = String . fromCharCode ( c ) ; S [ N + 1 ] = String . fromCharCode ( c ) ; for ( let i = 1 ; i <= N + 1 ; ++ i ) { if ( S [ i ] == String . fromCharCode ( c ) ) { let len = i - prev ; max_len = Math . max ( max_len , len ) ; prev = i ; } } ans = Math . min ( ans , max_len ) ; } return ans ; } let S = " " ; let N = S . length ; document . write ( MinimumLengthSubstring ( S , N ) ) ;

Index/key variables: i
Iterator variables: c, i
Javascript program:
function minimumHammingDistance ( S , K ) { let n = S . length ; let pref = new Array ( n ) ; pref [ 0 ] = S [ 0 ] - ' ' ; for ( let i = 1 ; i < n ; i ++ ) pref [ i ] = pref [ i - 1 ] + ( S [ i ] - ' ' ) ; let cnt = pref [ n - 1 ] ; let ans = cnt ; for ( let i = 0 ; i < n - K ; i ++ ) { let value = pref [ i + K - 1 ] - ( i - 1 >= 0 ? pref [ i - 1 ] : 0 ) ; ans = Math . min ( ans , cnt - value + ( K - value ) ) ; } return ans ; } let s = " " ; let K = 2 ; document . write ( minimumHammingDistance ( s , K ) ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function isPrime ( n ) { if ( n <= 1 ) return false ; else if ( n == 2 ) return true ; else if ( n % 2 == 0 ) return false ; for ( let i = 3 ; i <= Math . floor ( Math . sqrt ( n ) ) ; i += 2 ) { if ( n % i == 0 ) return false ; } return true ; } function checkPermutation ( s1 , s2 ) { let freq = new Array ( 26 ) ; for ( let i = 0 ; i < 26 ; i ++ ) freq [ i ] = 0 ; for ( let ch = 0 ; ch < s1 . length ; ch ++ ) { freq [ s1 [ ch ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] -- ; } for ( let ch = 0 ; ch < s2 . length ; ch ++ ) { freq [ s2 [ ch ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] ++ ; } let isAllChangesPrime = true ; for ( let i = 0 ; i < 26 ; i ++ ) { if ( freq [ i ] == 0 ) { continue ; } else if ( ! isPrime ( Math . abs ( freq [ i ] ) ) ) { isAllChangesPrime = false ; break ; } } if ( isAllChangesPrime ) { document . write ( " " ) ; } else { document . write ( " " ) ; } } let S1 = " " ; let S2 = " " ; checkPermutation ( S1 , S2 ) ;

Index/key variables: ch, i
Accumulator variables: ch, i
Iterator variables: ch, i
Boolean variables: isAllChangesPrime
Javascript program:
function isEqualSubstring ( str , x ) { let n = str . length ; let i = 0 ; while ( i < n && i < x ) { if ( str [ i ] !== str [ n - i - 1 ] ) { document . write ( " " ) ; return ; } i ++ ; } document . write ( " " ) ; } let str = " " ; let x = 3 ; isEqualSubstring ( str , x ) ;

Index/key variables: i
Accumulator variables: i
Javascript program:
function minimumOperations ( S , N ) { let ans = 0 ; let cntOne = 0 ; for ( let i = N - 1 ; i >= 0 ; i -- ) { if ( S [ i ] == ' ' ) { ans += cntOne ; cntOne *= 2 ; } else cntOne ++ ; } document . write ( ans ) ; } let S = " " ; let N = S . length ; minimumOperations ( S , N ) ;

Index/key variables: i
Accumulator variables: ans, cntOne, i
Iterator variables: i
Javascript program:
function differentBitwiseOR ( s1 , s2 ) { let n = s1 . length ; let t00 = 0 , t10 = 0 , t01 = 0 , t11 = 0 ; for ( let i = 0 ; i < n ; i ++ ) { if ( s1 [ i ] == ' ' && s2 [ i ] == ' ' ) { t00 ++ ; } if ( s1 [ i ] == ' ' && s2 [ i ] == ' ' ) { t10 ++ ; } if ( s1 [ i ] == ' ' && s2 [ i ] == ' ' ) { t11 ++ ; } if ( s1 [ i ] == ' ' && s2 [ i ] == ' ' ) { t01 ++ ; } } let ans = t00 * t10 + t01 * t10 + t00 * t11 ; document . write ( ans ) ; } let S1 = " " ; let S2 = " " ; differentBitwiseOR ( S1 , S2 ) ;

Index/key variables: i
Accumulator variables: i, t00, t01, t10, t11
Iterator variables: i
Javascript program:
function RemoveCharacters ( s ) { var ans = " " ; var c = new Array ( 26 ) ; var i ; for ( i = 0 ; i < 26 ; i ++ ) c [ i ] = 0 ; var pos = 0 ; for ( i = 0 ; i < s . length ; i ++ ) { if ( c [ s [ i ] . charCodeAt ( ) - 97 ] == 0 ) { c [ s [ i ] . charCodeAt ( ) - 97 ] = 1 ; pos = i ; ans += s [ i ] ; } } for ( i = pos + 1 ; i < s . length ; i ++ ) { if ( s [ i ] == s [ 0 ] ) { ans += s [ i ] ; break ; } } document . write ( ans ) ; } var S = " " ; RemoveCharacters ( S ) ;

Index/key variables: i
Accumulator variables: ans, i
Iterator variables: i
Javascript program:
function isPossible ( s , K ) { let valid = false ; let firstx = - 1 ; let n = s . length ; for ( let i = 1 ; i <= n / 2 ; ++ i ) { let x = ( s . substr ( 0 , i ) ) ; firstx = x ; let test = x . toString ( ) ; while ( test . length < s . length ) { x -= K ; test += x . toString ( ) ; } if ( test == s ) { valid = true ; break ; } } document . write ( ( valid == true ) ? " " : " " ) ; } let S = " " ; let K = 2 ; isPossible ( S , K ) ;

Accumulator variables: test, x
Iterator variables: i
Boolean variables: valid
Javascript program:
function changeCharacters ( S , N , K ) { let flag = 1 ; let count = 0 ; let st = new Array ( ) ; for ( let i = 0 ; i < N ; i ++ ) { if ( st . length == 0 ) { if ( S [ i ] == ' ' ) { flag = 0 ; break ; } count = 0 ; st . push ( S [ i ] ) ; } else { if ( S [ i ] == ' ' ) { count ++ ; if ( count == K ) { st . pop ( ) ; count = 0 ; } } else { count = 0 ; } } } if ( flag == 1 ) document . write ( " " ) ; else document . write ( " " ) ; } let S = " " ; let N = S . Length ; let K = 2 ; changeCharacters ( S , N , K ) ;

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Javascript program:
function prefixDivisble ( n ) { let i = 1 ; while ( n > 0 ) { if ( n % i != 0 ) return false ; n = parseInt ( n / 10 ) ; i ++ ; } return true ; } let n = 52248 ; if ( prefixDivisble ( n ) == true ) document . write ( " " ) ; else document . write ( " " ) ;

Accumulator variables: i
Javascript program:
function MinimumCost ( S , A , B ) { let count = 0 ; let group = 0 ; for ( let i = 0 ; i < S . length ; i ++ ) { if ( S [ i ] == ' ' ) { count += 1 ; } else { if ( count > 0 ) { group += 1 ; } count = 0 ; } } if ( count > 0 ) group += 1 ; if ( group == 0 ) { document . write ( 0 + " " ) ; } else { document . write ( Math . min ( A , B ) * ( group - 1 ) + B ) ; } } let A = 1 ; let B = 5 ; let S = " " ; MinimumCost ( S , A , B ) ;

Index/key variables: i
Accumulator variables: count, group, i
Iterator variables: i
Javascript program:
function isPrime ( x ) { if ( x <= 1 ) return false ; for ( let i = 2 ; i * i <= x ; i ++ ) { if ( i * i > x ) { break } if ( x % i == 0 ) return false ; } return true ; } function largestPrime ( s ) { let vec = [ [ " " , 0 ] ] ; let ans = 0 ; for ( let i = 0 ; i < s . length ; i ++ ) { let n = vec . length ; for ( let j = 0 ; j < n ; j ++ ) { let temp = vec [ j ] ; let str = temp [ 0 ] ; let val = temp [ 1 ] ; if ( s [ i ] == ' ' ) { temp [ 0 ] = str + ' ' ; temp [ 1 ] = ( ( val << 1 ) + 1 ) ; } else { temp [ 0 ] = str + ' ' ; temp [ 1 ] = ( ( val << 1 ) + 0 ) ; } vec . push ( temp ) ; let check = temp [ 1 ] ; if ( isPrime ( check ) ) { ans = Math . max ( ans , check ) ; break } } } if ( ans == 0 ) document . write ( - 1 + " " ) ; else document . write ( ans + " " ) ; } let s = " " ; largestPrime ( s ) ;

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
function isPrime ( num ) { let flag = false ; if ( num > 1 ) { for ( let i = 2 ; i < num ; i ++ ) { if ( ( num % i ) == 0 ) { flag = true ; break ; } } } if ( flag ) return false ; else return true ; } function order ( x ) { let n = 0 ; while ( x != 0 ) { n = n + 1 ; x = x / 10 ; } return n ; } function isArmstrong ( x ) { let n = order ( x ) ; let temp = x ; let sum1 = 0 ; while ( temp != 0 ) { let r = temp % 10 ; sum1 = sum1 + Math . pow ( r , n ) ; temp = temp / 10 ; } return ( sum1 == x ) ; } function count_armstrong ( li ) { let c = 0 ; for ( let ele of li ) { let val = 0 ; for ( let che of ele ) val += che . charCodeAt ( 0 ) ; if ( isArmstrong ( val ) ) c += 1 ; } return c ; } function count_prime ( li ) { let c = 0 ; for ( let ele of li ) { let val = 0 ; for ( let che of ele ) val += che . charCodeAt ( 0 ) ; if ( isPrime ( val ) ) c += 1 ; } return c ; } let arr = [ " " , " " , " " , " " , " " , " " , " " ] ; document . write ( " " + count_armstrong ( arr ) + " " ) ; document . write ( " " + count_prime ( arr ) + " " ) ;

Accumulator variables: c, i, val
Iterator variables: che, ele, i
Boolean variables: flag
Javascript program:
function findMinimumCost ( s , N ) { let count_1 = 0 , count_0 = 0 ; for ( let i = 0 ; i < N ; i ++ ) { if ( s [ i ] == ' ' ) count_1 ++ ; else count_0 ++ ; } let k = Math . abs ( count_0 - count_1 ) ; if ( count_1 == N count_0 == N ) document . write ( - 1 ) ; else document . write ( k / 2 ) ; } let S = " " ; let N = S . length ; findMinimumCost ( S , N ) ;

Index/key variables: i
Accumulator variables: count_0, count_1, i
Iterator variables: i
Javascript program:
function findMinimumTime ( s , N , K ) { if ( N == 0 ) { document . write ( 0 ) ; return ; } let maxfreq = Number . MIN_SAFE_INTEGER ; let maxchar ; let um = new Map ( ) ; for ( let i = 0 ; i < N ; i ++ ) { if ( um . has ( s [ i ] ) ) { um . set ( s [ i ] , um . get ( s [ i ] ) + 1 ) } else { um . set ( s [ i ] , 1 ) } if ( um . get ( S [ i ] ) > maxfreq ) { maxfreq = um . get ( S [ i ] ) ; maxchar = S [ i ] ; } } let emptySlots = ( maxfreq - 1 ) * K ; for ( let it of um ) { if ( it [ 0 ] == maxchar ) continue ; emptySlots -= Math . min ( it [ 1 ] , maxfreq - 1 ) ; } let ans = N + Math . max ( 0 , emptySlots ) ; document . write ( ans ) ; } let S = " " ; let K = 2 ; let N = S . length ; findMinimumTime ( S , N , K ) ;

Index/key variables: i
Accumulator variables: emptySlots, i
Iterator variables: i, it
Javascript program:
function canMakeEqual ( S ) { var N = S . length ; var weightOfString = 0 ; for ( var i = 0 ; i < N ; i ++ ) { weightOfString += S . charAt ( i ) . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) + 1 ; } if ( weightOfString % N == 0 ) document . write ( " " ) ; else document . write ( " " ) ; } var S = " " ; canMakeEqual ( S ) ;

Accumulator variables: i, weightOfString
Iterator variables: i
Javascript program:
function addFrequencyToCharacter ( Str ) { var frequency = Array . from ( { length : 26 } , ( _ , i ) => 0 ) ; var N = Str . length ; var S = Str . split ( ' ' ) ; for ( var i = 0 ; i < N ; i ++ ) { frequency [ S [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] += 1 ; } for ( var i = 0 ; i < N ; i ++ ) { var add = frequency [ S [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] % 26 ; if ( ( S [ i ] . charCodeAt ( 0 ) ) + add <= ( ' ' ) . charCodeAt ( 0 ) ) S [ i ] = String . fromCharCode ( ( S [ i ] . charCodeAt ( 0 ) ) + add ) ; else { add = ( ( S [ i ] . charCodeAt ( 0 ) ) + add ) - ( ( ' ' ) . charCodeAt ( 0 ) ) ; S [ i ] = String . fromCharCode ( ( ' ' . charCodeAt ( 0 ) ) + add - 1 ) ; } } document . write ( S . join ( ' ' ) ) ; } var S = " " ; addFrequencyToCharacter ( S ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function findMinimumTime ( tasks , K ) { var map = new Map ( ) ; var curr_time = 0 ; tasks . split ( ' ' ) . forEach ( c => { if ( map . has ( c ) ) { if ( curr_time - map . get ( c ) <= K ) { curr_time += K - ( curr_time - map . get ( c ) ) + 1 ; } } map . set ( c , curr_time ) ; curr_time ++ ; } ) ; document . write ( curr_time ) ; } var S = " " ; var K = 2 ; findMinimumTime ( S , K ) ;

Accumulator variables: curr_time
Javascript program:
function checkforSubsequence ( S , target ) { var s = [ ] ; for ( var i = 0 ; i < target . length ; i ++ ) { s . push ( target [ i ] ) ; } for ( var i = S . length - 1 ; i >= 0 ; i -- ) { if ( s . length == 0 ) { document . write ( " " ) ; return ; } if ( S [ i ] == s [ s . length - 1 ] ) { s . pop ( ) ; } } if ( s . length == 0 ) document . write ( " " ) ; else document . write ( " " ) ; } var S = " " ; var target = " " ; checkforSubsequence ( S , target ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
let digits = " " , sign = " " ; let dot = " " , ex = " " ; let dfa = new Array ( 11 ) ; for ( let i = 0 ; i < 11 ; i ++ ) { dfa [ i ] = new Array ( 5 ) ; } function makeDFA ( ) { dfa [ 0 ] [ 0 ] = 1 ; dfa [ 1 ] [ 0 ] = 1 ; dfa [ 1 ] [ 2 ] = 3 ; dfa [ 1 ] [ 3 ] = 2 ; dfa [ 1 ] [ 4 ] = 6 ; dfa [ 3 ] [ 0 ] = 4 ; dfa [ 4 ] [ 0 ] = 4 ; dfa [ 4 ] [ 3 ] = 5 ; dfa [ 4 ] [ 4 ] = 6 ; dfa [ 6 ] [ 0 ] = 8 ; dfa [ 6 ] [ 1 ] = 7 ; dfa [ 7 ] [ 0 ] = 8 ; dfa [ 8 ] [ 0 ] = 8 ; dfa [ 8 ] [ 3 ] = 9 ; } function buildDFA ( ) { for ( let i = 0 ; i < 11 ; i ++ ) for ( let j = 0 ; j < 5 ; j ++ ) dfa [ i ] [ j ] = 10 ; makeDFA ( ) ; } function checkDFA ( s ) { buildDFA ( ) ; let currentstate = 0 ; for ( let i = 0 ; i < s . length ; i ++ ) { if ( digits . indexOf ( s [ i ] ) != - 1 ) currentstate = dfa [ currentstate ] [ 0 ] ; else if ( sign . indexOf ( s [ i ] ) != - 1 ) currentstate = dfa [ currentstate ] [ 1 ] ; else if ( dot . indexOf ( s [ i ] ) != - 1 ) currentstate = dfa [ currentstate ] [ 2 ] ; else if ( ex . indexOf ( s [ i ] ) != - 1 ) currentstate = dfa [ currentstate ] [ 4 ] ; else currentstate = dfa [ currentstate ] [ 3 ] ; } if ( currentstate == 1 currentstate == 4 currentstate == 8 ) { document . write ( " " ) ; } else { document . write ( " " ) ; } } let S = " " ; checkDFA ( S ) ;

Index/key variables: currentstate, i, j
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
function printSentence ( S ) { let nums = [ " " , " " , " " , " " , " " , " " , " " , " " , " " , " " ] ; let str = S . split ( " " ) ; let i = 0 ; while ( i < str . length ) { if ( str [ i ] == ' ' ) { i ++ ; continue ; } let count = 0 ; while ( i + 1 < str . length && str [ i ] == str [ i + 1 ] ) { if ( count == 2 && ( ( str [ i ] >= ' ' && str [ i ] <= ' ' ) || ( str [ i ] == ' ' ) ) ) break ; else if ( count == 3 && ( str [ i ] == ' ' str [ i ] == ' ' ) ) break ; count ++ ; i ++ ; if ( i == str . length ) break ; } if ( str [ i ] == ' ' str [ i ] == ' ' ) { document . write ( nums [ str [ i ] . charCodeAt ( 0 ) - 48 ] [ count % 4 ] ) ; } else { document . write ( nums [ str [ i ] . charCodeAt ( 0 ) - 48 ] [ count % 3 ] ) ; } i ++ ; } } let str = " " ; printSentence ( str ) ;

Index/key variables: i
Accumulator variables: count, i
Javascript program:
function getString ( N ) { let ans = " " while ( N >= 26 ) { ans += ' ' N -= 26 } ans += String . fromCharCode ( N + ' ' . charCodeAt ( 0 ) - 1 ) return ans } let N = 30 document . write ( getString ( N ) )

Accumulator variables: N, ans
Javascript program:
function countSamePrefixSuffix ( s , n ) { var prefix = " " ; for ( let i = 0 ; i < n - 1 ; i ++ ) { prefix += s . charAt ( i ) ; var suffix = s . substring ( n - 1 - i , n ) ; if ( prefix == suffix ) { document . write ( prefix . length + " " ) ; } } } let S = " " ; let N = S . length ; countSamePrefixSuffix ( S , N ) ;

Accumulator variables: i, prefix
Iterator variables: i
Javascript program:
function countStringPairs ( a , n ) { let ans = 0 ; let s = new Map ( ) ; for ( let i = 0 ; i < n ; i ++ ) { if ( ! s . has ( a [ i ] ) ) s . set ( a [ i ] , 0 ) ; s . set ( a [ i ] , s . get ( a [ i ] ) + 1 ) ; } for ( let i = 0 ; i < n ; i ++ ) { for ( let j = i + 1 ; j < n ; j ++ ) { let p = ( a [ i ] ) . split ( " " ) ; let q = ( a [ j ] ) . split ( " " ) ; if ( p [ 0 ] != q [ 0 ] ) { let t = p [ 0 ] ; p [ 0 ] = q [ 0 ] ; q [ 0 ] = t ; if ( ! s . has ( p . join ( " " ) ) && ! s . has ( q . join ( " " ) ) ) { ans ++ ; } } } } document . write ( ans ) ; } let arr = [ " " , " " , " " ] ; let N = arr . length ; countStringPairs ( arr , N ) ;

Index/key variables: i, j
Accumulator variables: ans, i, j
Iterator variables: i, j
Javascript program:
function minimumMoves ( s , n , k ) { if ( n & 1 ) { document . write ( " " ) ; return ; } var countOpen = 0 ; var i ; for ( i = 0 ; i < s . length ; i ++ ) { if ( s [ i ] == " " ) countOpen ++ ; } var countClose = 0 ; for ( i = 0 ; i < s . length ; i ++ ) { if ( s [ i ] == " " ) countClose ++ ; } ; if ( countOpen != countClose ) { document . write ( " " ) ; return ; } var ans = 0 ; var cnt = 0 ; for ( i = 0 ; i < n ; ++ i ) { if ( s [ i ] == ' ' ) ++ cnt ; else { -- cnt ; if ( cnt < 0 ) { cnt = 0 ; ++ ans ; } } } if ( ans <= k ) document . write ( " " ) ; else document . write ( " " ) ; } var S = " " ; var K = 1 ; minimumMoves ( S , S . length , K ) ;

Index/key variables: i
Accumulator variables: countClose, countOpen, i
Iterator variables: i
Javascript program:
function findRandom ( ) { let num = ( 1 + parseInt ( ( Math . random ( ) * 100 ) ) ) % 2 ; return num ; } function generateBinaryString ( N ) { let S = " " ; for ( let i = 0 ; i < N ; i ++ ) { let x = findRandom ( ) ; S += ( x ) . toString ( ) ; } document . write ( S ) } let N = 7 ; generateBinaryString ( N ) ;

Accumulator variables: S, i
Iterator variables: i
Javascript program:
function checkPalindrome ( s ) { let a = [ 0 ] let o = 0 , e = 0 ; for ( let i = 0 ; i < s . length ; i ++ ) a [ s . charCodeAt ( i ) - 97 ] ++ ; for ( let i = 0 ; i < 26 ; i ++ ) { if ( a [ i ] == 1 ) o ++ ; else if ( a [ i ] % 2 == 0 && a [ i ] != 0 ) e += ( a [ i ] / 2 ) ; } if ( e >= o ) document . write ( " " ) else { o = o - e ; for ( let i = 0 ; i < 26 ; i ++ ) { if ( o <= 0 ) break ; if ( o > 0 && a [ i ] % 2 == 1 && a [ i ] > 2 ) { let k = o ; o = o - a [ i ] / 2 ; if ( o > 0 2 * k + 1 == a [ i ] ) { o ++ ; a [ i ] = 1 ; } } } if ( o <= 0 ) document . write ( " " ) else document . write ( " " ) } } let S = " " ; checkPalindrome ( S ) ;

Index/key variables: i
Accumulator variables: e, i, o
Iterator variables: i
Javascript program:
function maximumTime ( str ) { var s = str . split ( " " ) ; if ( s [ 0 ] == ' ' ) { if ( ( s [ 1 ] == ' ' ) || ( s [ 1 ] >= ' ' && s [ 1 ] < ' ' ) ) { s [ 0 ] = ' ' ; } else { s [ 0 ] = ' ' ; } } if ( s [ 1 ] == ' ' ) { if ( s [ 0 ] == ' ' ) { s [ 1 ] = ' ' ; } else { s [ 1 ] = ' ' ; } } if ( s [ 3 ] == ' ' ) { s [ 3 ] = ' ' ; } if ( s [ 4 ] == ' ' ) { s [ 4 ] = ' ' ; } for ( var i = 0 ; i < s . length ; i ++ ) document . write ( s [ i ] ) ; } var S = " " ; maximumTime ( S ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function nearestPowerOfTwoUtil ( freq ) { freq . forEach ( ( value , key ) => { document . write ( key + " " ) ; var lg = parseInt ( Math . log2 ( value ) ) ; var a = Math . pow ( 2 , lg ) ; var b = Math . pow ( 2 , lg + 1 ) ; if ( ( value - a ) < ( b - value ) ) { document . write ( a + " " ) ; } else { document . write ( b + " " ) ; } } ) ; } function nearestPowerOfTwo ( S ) { var N = S . length ; var freq = new Map ( ) ; for ( var i = 0 ; i < N ; i ++ ) { if ( freq . has ( S [ i ] ) ) { freq . set ( S [ i ] , freq . get ( S [ i ] ) + 1 ) } else { freq . set ( S [ i ] , 1 ) } } nearestPowerOfTwoUtil ( freq ) ; } var N = " " ; nearestPowerOfTwo ( N ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function gcd ( a , b ) { if ( b == 0 ) return a ; return gcd ( b , a % b ) ; } function lcm ( a , b ) { return ( a / gcd ( a , b ) ) * b ; } function findSmallestString ( s , t ) { let n = s . length , m = t . length ; let l = lcm ( n , m ) ; let s1 = " " , t1 = " " ; for ( let i = 0 ; i < l / n ; i ++ ) { s1 += s ; } for ( let i = 0 ; i < l / m ; i ++ ) { t1 += t ; } if ( s1 == ( t1 ) ) { document . write ( s1 + " " ) ; } else { document . write ( - 1 + " " ) ; } } let S = " " , T = " " ; findSmallestString ( S , T ) ;

Accumulator variables: i, s1, t1
Iterator variables: i
Javascript program:
function minRemovals ( str , N ) { let ans = 0 ; let X = false ; for ( i = 0 ; i < N ; i ++ ) { if ( str [ i ] == ' ' ) { ans ++ ; while ( str [ i ] == ' ' ) { i ++ ; } } else { X = true ; } } if ( ! X ) return 1 ; if ( str [ 0 ] == ' ' && str [ N - 1 ] == ' ' ) { ans -- ; } return ans ; } let S = " " ; let N = S . length ; document . write ( minRemovals ( S , N ) ) ;

Index/key variables: i
Accumulator variables: ans, i
Iterator variables: i
Boolean variables: X
Javascript program:
function minimumDeletions ( s ) { var right_0 = 0 ; var i ; for ( i = 0 ; i < s . length ; i ++ ) { if ( s [ i ] == ' ' ) right_0 ++ ; } var left_1 = 0 ; var n = s . length ; var res = 2147483647 ; for ( i = 0 ; i < n ; i ++ ) { if ( s [ i ] == ' ' ) { right_0 -= 1 ; } else { left_1 += 1 ; } res = Math . min ( res , right_0 + left_1 ) ; } return res ; } var s = " " ; var count = minimumDeletions ( s ) ; document . write ( count ) ;

Index/key variables: i
Accumulator variables: i, left_1, right_0
Iterator variables: i
Javascript program:
function canMakeSame ( s1 , s2 ) { var ans = 0 ; if ( s1 . length != s2 . length ) { return - 1 ; } var N = s1 . length ; for ( var i = 0 ; i < N ; i ++ ) { if ( s1 [ i ] != s2 [ i ] ) { while ( i < s1 . length && s1 [ i ] != s2 [ i ] ) { i ++ ; } ans ++ ; } } return ans ; } var S1 = " " ; var S2 = " " ; document . write ( canMakeSame ( S1 , S2 ) ) ;

Index/key variables: i
Accumulator variables: ans, i
Iterator variables: i
Javascript program:
function count ( S , X , Y ) { let N = S . length ; let temp_x = 0 , temp_y = 0 ; let count = 0 ; let s = new Set ( ) ; s . add ( ( X + " " + Y ) ) ; for ( let i = 0 ; i < N ; i ++ ) { temp_x = X ; temp_y = Y ; if ( S [ i ] == ' ' ) { X ++ ; } else if ( S [ i ] == ' ' ) { X -- ; } else if ( S [ i ] == ' ' ) { Y ++ ; } else { Y -- ; } if ( s . has ( ( temp_x + X ) + " " + ( temp_y + Y ) ) ) { count ++ ; } else { s . add ( ( temp_x + X ) + " " + ( temp_y + Y ) ) ; } } return count ; } let S = " " ; let X = 0 , Y = 0 ; document . write ( count ( S , X , Y ) ) ;

Index/key variables: i
Accumulator variables: X, Y, count, i
Iterator variables: i
Javascript program:
function countTotalFrequencies ( S1 , S2 ) { var bset = new Set ( ) ; for ( var i = 0 ; i < S1 . length ; i ++ ) { bset . add ( S1 [ i ] ) ; } var count = 0 ; for ( var i = 0 ; i < S2 . length ; i ++ ) { if ( bset . has ( S2 [ i ] ) ) count += 1 ; } document . write ( count ) ; } var S1 = " " ; var S2 = " " ; countTotalFrequencies ( S1 , S2 ) ;

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Javascript program:
function nonDecreasing ( s ) { let size = s . length ; var c = ' ' ; for ( let i = 0 ; i < size ; i ++ ) { if ( s [ i ] == ' ' ) { continue ; } else if ( ( s [ i ] != ' ' ) && ( s [ i ] < c ) ) { return 0 ; } else { c = s [ i ] ; } } return 1 ; } let S = " " ; if ( nonDecreasing ( S . split ( ' ' ) ) ) document . write ( " " + " " ) ; else document . write ( " " + " " ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function min_length ( str ) { var n = str . length ; var total_zeros = 0 ; var total_ones = 0 ; for ( var i = 0 ; i < n ; i ++ ) { if ( str [ i ] == ' ' ) total_zeros ++ ; else total_ones ++ ; } var ans = Math . min ( total_zeros , total_ones ) ; var cur_zeros = 0 , cur_ones = 0 ; for ( var i = 0 ; i < str . length ; i ++ ) { if ( str [ i ] == ' ' ) cur_zeros ++ ; else cur_ones ++ ; ans = Math . min ( ans , cur_ones + ( total_zeros - cur_zeros ) ) ; } document . write ( ans ) ; } var str = " " ; min_length ( str ) ;

Index/key variables: i
Accumulator variables: cur_ones, cur_zeros, i, total_ones, total_zeros
Iterator variables: i