dhyuti-n/xlcost-variable-roles huggingface dataset:
Javascript program:
function printExpansion ( str ) { var suff = " " ; for ( var i = str . length - 1 ; i >= 0 ; i -- ) { suff = suff + str [ i ] ; document . write ( suff ) ; } } var str = " " ; printExpansion ( str ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function logicalExpressionEvaluation ( str ) { let arr = [ ] ; for ( let i = str . length - 1 ; i >= 0 ; i -- ) { if ( str [ i ] == ' ' ) { let s = [ ] ; while ( arr [ arr . length - 1 ] != ' ' ) { s . push ( arr [ arr . length - 1 ] ) ; arr . pop ( ) ; } arr . pop ( ) ; if ( s . length == 3 ) { arr . push ( s [ 2 ] == ' ' ? ' ' : ' ' ) ; } else if ( s . length == 5 ) { let a = s [ 0 ] . charCodeAt ( 0 ) - 48 , b = s [ 4 ] . charCodeAt ( 0 ) - 48 , c ; if ( s [ 2 ] == ' ' ) { c = a & b ; } else { c = a | b ; } arr . push ( String . fromCharCode ( c + 48 ) ) ; } } else { arr . push ( str [ i ] ) ; } } return arr [ arr . length - 1 ] ; } let str = " " ; document . write ( logicalExpressionEvaluation ( str ) ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function count ( s , k ) { var n = s . length ; var d = 0 , i ; var count = 0 ; for ( i = 0 ; i < n ; i ++ ) d += s [ i ] . charCodeAt ( 0 ) ; if ( d % k === 0 ) { count += 1 ; } for ( i = k ; i < n ; i ++ ) { var prev = s [ i - k ] ; d -= prev . charCodeAt ( 0 ) ; d += s [ i ] . charCodeAt ( 0 ) ; if ( d % k === 0 ) count += 1 ; } return count ; } var s = " " ; var k = 3 ; var ans = count ( s , k ) ; document . write ( ans ) ;

Index/key variables: i
Accumulator variables: count, d, i
Iterator variables: i
Javascript program:
function printFinalString ( s ) { var i , n ; n = s . length ; var x = 0 , y = 0 ; for ( i = 0 ; i < n ; i ++ ) { if ( s [ i ] == ' ' ) x ++ ; else y ++ ; } var finalString = " " ; if ( x > y ) for ( i = 0 ; i < x - y ; i ++ ) finalString += " " ; else for ( i = 0 ; i < y - x ; i ++ ) finalString += " " ; return finalString ; } var s = " " ; document . write ( printFinalString ( s ) ) ;

Index/key variables: i
Accumulator variables: finalString, i, x, y
Iterator variables: i
Javascript program:
function K_String ( s , k ) { let n = s . length ; let fre = new Array ( 26 ) ; for ( let i = 0 ; i < fre . length ; i ++ ) { fre [ i ] = 0 ; } for ( let i = 0 ; i < n ; i ++ ) fre [ s [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] ++ ; let str = " " ; for ( let i = 0 ; i < 26 ; i ++ ) { if ( fre [ i ] % k == 0 ) { let x = Math . floor ( fre [ i ] / k ) ; while ( x != 0 ) { str += String . fromCharCode ( i + ' ' . charCodeAt ( 0 ) ) ; x -- ; } } else { return " " ; } } return str ; } let s = " " ; let k = 2 ; document . write ( K_String ( s , k ) ) ;

Index/key variables: i
Accumulator variables: i, str, x
Iterator variables: i
Javascript program:
function check ( s ) { var i , j ; var fr = Array ( 26 ) . fill ( 0 ) ; var n = s . length ; for ( i = 0 ; i < n ; i ++ ) { var x = s [ i ] ; fr [ x . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] += 1 ; } var minimum = 10000000000 ; for ( i = 0 ; i < 26 ; i ++ ) { for ( j = i + 1 ; j < 26 ; j ++ ) { var z = fr [ i ] + fr [ j ] ; minimum = Math . min ( minimum , n - z ) ; } } return minimum ; } var s = " " ; document . write ( check ( s ) ) ;

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
function CountCharacters ( str , l , r ) { let cnt = 0 ; let m = new Map ( ) ; let len = str . length ; for ( let i = 0 ; i < len ; i ++ ) { if ( ! ( l <= str [ i ] . charCodeAt ( 0 ) && str [ i ] . charCodeAt ( 0 ) <= r ) ) { cnt ++ ; if ( ! m . has ( str [ i ] ) ) { m . set ( str [ i ] , 0 ) ; document . write ( str [ i ] + " " ) ; } m . set ( str [ i ] , m . get ( str [ i ] + 1 ) ) ; } } return cnt ; } let str = " " ; let l = 102 , r = 111 ; document . write ( " " + " " ) ; document . write ( " " + CountCharacters ( str , l , r ) ) ;

Index/key variables: i
Accumulator variables: cnt, i
Iterator variables: i
Javascript program:
function CountWords ( str , k ) { let sum = 0 ; let NumberOfWords = 0 ; let counter = 0 ; let len = str . length ; for ( let i = 0 ; i < len ; ++ i ) { if ( str [ i ] == " " ) { if ( sum < k ) { counter ++ ; } sum = 0 ; NumberOfWords ++ ; } else { sum += str . charCodeAt ( i ) ; } } NumberOfWords ++ ; if ( sum < k ) { counter ++ ; } document . write ( " " + " " + counter + " " ) ; document . write ( " " + " " + ( NumberOfWords - counter ) + " " ) ; } let str = " " ; let k = 400 ; CountWords ( str , k ) ;

Index/key variables: i
Accumulator variables: NumberOfWords, counter, sum
Iterator variables: i
Javascript program:
function separateChar ( str ) { var n = str . length , digitSum = 0 ; var alphabetSum = 0 , j = 0 ; for ( var i = 0 ; i < n ; i ++ ) { if ( str [ i ] >= ' ' && str [ i ] <= ' ' ) digitSum += ( str [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ) ; else { alphabetSum += ( str [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) + 1 ) ; alphabetSum %= 26 ; } } var sumStr = digitSum . toString ( ) ; var alphabetStr = String . fromCharCode ( alphabetSum + ' ' . charCodeAt ( 0 ) - 1 ) ; sumStr += alphabetStr ; return sumStr ; } var str = " " ; document . write ( separateChar ( str ) ) ;

Index/key variables: i
Accumulator variables: alphabetSum, digitSum, i, sumStr
Iterator variables: i
Javascript program:
var MAX_CHAR = 26 ; function countPalindrome ( str ) { var n = str . length ; var sum = 0 ; var hashTable = Array ( MAX_CHAR ) . fill ( 0 ) ; for ( var i = 0 ; i < n ; i ++ ) hashTable [ str [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] ++ ; for ( var i = 0 ; i < 26 ; i ++ ) { if ( hashTable [ i ] ) sum += ( hashTable [ i ] * ( hashTable [ i ] + 1 ) / 2 ) ; } return sum ; } var str = " " ; document . write ( countPalindrome ( str ) ) ;

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Javascript program:
function countConsecutive ( s ) { let count = 0 ; for ( let i = 0 ; i < s . length ; i ++ ) { if ( s [ i ] == s [ i + 1 ] ) i ++ ; else count ++ ; } return count ; } let str = " " ; document . write ( countConsecutive ( str ) ) ;

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Javascript program:
function check_digits ( n ) { while ( n > 1 ) { if ( ( n % 10 ) % 2 == 0 ) return 0 ; n = parseInt ( n / 10 ) ; } return 1 ; } function smallest_number ( n ) { for ( i = n ; ; i ++ ) if ( check_digits ( i ) ) return i ; } let N = 2397 ; document . write ( smallest_number ( N ) ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function smallestNumber ( n ) { var num = 0 ; var s = " " ; var duplicate = n ; while ( n ) { s = String . fromCharCode ( n % 10 + 48 ) + s ; n = parseInt ( n / 10 ) ; } var index = - 1 ; for ( var i = 0 ; i < s . length ; i ++ ) { var digit = s [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ; if ( ( digit & 1 ) == 0 ) { index = i ; break ; } } if ( index == - 1 ) return duplicate ; for ( var i = 0 ; i < index ; i ++ ) num = num * 10 + ( s [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ) ; num = num * 10 + ( s [ index ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) + 1 ) ; for ( var i = index + 1 ; i < s . length ; i ++ ) num = num * 10 + 1 ; return num ; } var N = 2397 ; document . write ( smallestNumber ( N ) ) ;

Index/key variables: i, index
Accumulator variables: i
Iterator variables: i
Javascript program:
function CountCharacters ( str , l , r ) { let cnt = 0 ; let len = str . length ; for ( let i = 0 ; i < len ; i ++ ) { if ( l <= str [ i ] . charCodeAt ( 0 ) && str [ i ] . charCodeAt ( 0 ) <= r ) { cnt ++ ; document . write ( str [ i ] + " " ) ; } } return cnt ; } let str = " " ; let l = 102 , r = 111 ; document . write ( " " + " " ) ; document . write ( " " + CountCharacters ( str , l , r ) ) ;

Index/key variables: i
Accumulator variables: cnt, i
Iterator variables: i
Javascript program:
function minSteps ( str ) { let count = 0 ; for ( let i = 0 ; i < str . length - 2 ; i ++ ) { if ( ( str [ i ] ) == ' ' ) { if ( str [ i + 1 ] == ' ' ) { if ( str [ i + 2 ] == ' ' ) { count ++ ; i += 2 ; } } } } return count ; } let str = " " ; document . write ( minSteps ( str ) ) ;

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Javascript program:
function SieveOfEratosthenes ( prime , p_size ) { prime [ 0 ] = false ; prime [ 1 ] = false ; for ( var p = 2 ; p * p <= p_size ; p ++ ) { if ( prime [ p ] ) { for ( var i = p * 2 ; i <= p_size ; i += p ) prime [ i ] = false ; } } } function xorOfPrime ( s ) { var prime = Array ( 100005 ) . fill ( true ) ; SieveOfEratosthenes ( prime , 10005 ) ; var i , j ; var m = new Map ( ) ; for ( i = 0 ; i < s . length ; i ++ ) { if ( m . has ( s [ i ] ) ) { m . set ( s [ i ] , m . get ( s [ i ] ) + 1 ) ; } else { m . set ( s [ i ] , 1 ) ; } } var result = 0 ; var flag = 0 ; m . forEach ( ( value , key ) => { if ( prime [ value ] ) { result ^= value ; flag = 1 ; } } ) ; if ( ! flag ) return - 1 ; return result ; } var s = " " ; document . write ( xorOfPrime ( s ) ) ;

Index/key variables: i, p, value
Accumulator variables: i, p, result
Iterator variables: i, p
Javascript program:
function CountCharacters ( str , k ) { let cnt = 0 ; let len = str . length ; for ( let i = 0 ; i < len ; i ++ ) { if ( str [ i ] . charCodeAt ( 0 ) < k ) cnt ++ ; } return cnt ; } let str = " " ; let k = 90 ; let count = CountCharacters ( str , k ) ; document . write ( " " + count + " " ) ; document . write ( " " + ( str . length - count ) ) ;

Index/key variables: i
Accumulator variables: cnt, i
Iterator variables: i
Javascript program:
var seen = new Set ( ) ; var edges = [ ] ; function dfs ( node , k , A ) { for ( var i = 0 ; i < k ; ++ i ) { var str = node + A [ i ] ; if ( ! seen . has ( str ) ) { seen . add ( str ) ; dfs ( str . substring ( 1 ) , k , A ) ; edges . push ( i ) ; } } } function deBruijn ( n , k , A ) { seen = new Set ( ) ; edges = [ ] ; var startingNode = A [ 0 ] . repeat ( n - 1 ) ; dfs ( startingNode , k , A ) ; var S = " " ; var l = Math . pow ( k , n ) ; for ( var i = 0 ; i < l ; ++ i ) S += A [ edges [ i ] ] ; S += startingNode ; return S ; } function strings ( n , charAt ) { var str = " " ; for ( var i = 0 ; i < n ; i ++ ) str += charAt ; return str ; } var n = 3 , k = 2 ; var A = " " ; document . write ( deBruijn ( n , k , A ) ) ;

Index/key variables: i
Accumulator variables: S, i, str
Iterator variables: i
Javascript program:
function countWords ( str ) { let count = 1 ; for ( let i = 1 ; i < str . length - 1 ; i ++ ) { if ( str [ i ] >= ' ' && str [ i ] <= ' ' ) count ++ ; } return count ; } let str = " " ; document . write ( countWords ( str ) ) ;

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Javascript program:
function isFibonacci ( s ) { var m = new Map ( ) ; for ( var i = 0 ; i < s . length ; i ++ ) { if ( m . has ( s [ i ] ) ) { m . set ( s [ i ] , m . get ( s [ i ] ) ) ; } else { m . set ( s [ i ] , 1 ) ; } } var v = [ ] ; var n = m . length ; var a = 1 , b = 1 ; var c ; v . push ( a ) ; v . push ( b ) ; for ( var i = 0 ; i < n - 2 ; i ++ ) { v . push ( a + b ) ; c = a + b ; a = b ; b = c ; } var flag = 1 ; var i = 0 ; m . forEach ( ( value , key ) => { if ( value != v [ i ] ) { flag = 0 ; } } ) ; if ( flag == 1 ) return " " ; else return " " ; } var s = " " ; document . write ( isFibonacci ( s ) ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function smallest ( s ) { let l = s . length ; let ans = " " ; for ( let i = 0 ; i < l - 1 ; i ++ ) { if ( s [ i ] > s [ i + 1 ] ) { for ( let j = 0 ; j < l ; j ++ ) { if ( i != j ) { ans += s [ j ] ; } } return ans ; } } ans = s . substring ( 0 , l - 1 ) ; return ans ; } let s = " " ; document . write ( smallest ( s ) ) ;

Index/key variables: i, j
Accumulator variables: ans, i, j
Iterator variables: i, j
Javascript program:
function fact ( n ) { let f = 1 ; for ( let i = 2 ; i <= n ; i ++ ) { f = f * i ; } return f ; } function npr ( n , r ) { return fact ( n ) / fact ( n - r ) ; } function countPermutations ( str ) { let even = Math . floor ( str . length / 2 ) ; let odd = str . length - even ; let ways = 0 ; let freq = new Array ( 26 ) . fill ( 0 ) ; for ( let i = 0 ; i < str . length ; i ++ ) { ++ freq [ str . charCodeAt ( i ) - ' ' . charCodeAt ( 0 ) ] ; } let nvowels = freq [ 0 ] + freq [ 4 ] + freq [ 8 ] + freq [ 14 ] + freq [ 20 ] ; let nconsonants = str . length - nvowels ; ways = npr ( odd , nvowels ) * npr ( nconsonants , nconsonants ) ; return ways ; } let str = " " ; document . write ( countPermutations ( str ) ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function replacingConsonants ( s ) { var nVowel = " " ; for ( var i = 0 ; i < s . length ; i ++ ) s [ i ] = nVowel [ s [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] ; return s . join ( ' ' ) ; } var s = " " . split ( ' ' ) ; document . write ( replacingConsonants ( s ) ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function isVowel ( ch ) { if ( ch != ' ' && ch != ' ' && ch != ' ' && ch != ' ' && ch != ' ' ) return false ; return true ; } function replaceConsonants ( s ) { for ( var i = 0 ; i < s . length ; i ++ ) { if ( ! isVowel ( s [ i ] ) ) { if ( s [ i ] == ' ' ) s [ i ] = ' ' ; else { s [ i ] = String . fromCharCode ( s [ i ] . charCodeAt ( 0 ) + 1 ) ; if ( isVowel ( s [ i ] ) ) s [ i ] = String . fromCharCode ( s [ i ] . charCodeAt ( 0 ) + 1 ) ; } } } return s . join ( ' ' ) ; } var s = " " . split ( ' ' ) ; document . write ( replaceConsonants ( s ) ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
let MAX_CHAR = 26 ; function removeChars ( str , k ) { let hash = new Array ( MAX_CHAR ) ; for ( let i = 0 ; i < MAX_CHAR ; i ++ ) hash [ i ] = 0 ; let n = str . length ; for ( let i = 0 ; i < n ; ++ i ) { hash [ str [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] ++ ; } let res = " " ; for ( let i = 0 ; i < n ; ++ i ) { if ( hash [ str [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] >= k ) { res += str [ i ] ; } } return res ; } let str = " " ; let k = 2 ; document . write ( removeChars ( str , k ) ) ;

Index/key variables: i
Accumulator variables: i, res
Iterator variables: i
Javascript program:
function countOnOff ( n ) { var Led = [ 6 , 2 , 5 , 5 , 4 , 5 , 6 , 3 , 7 , 5 ] ; var len = n . length ; var sum = Led [ n . charAt ( 0 ) - ' ' ] ; for ( i = 1 ; i < len ; i ++ ) { sum = sum + Math . abs ( Led [ n . charAt ( i ) - ' ' ] - Led [ n . charAt ( i - 1 ) - ' ' ] ) ; } return sum ; } n = " " ; document . write ( countOnOff ( n ) ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function check ( s ) { var freq = Array ( 26 ) . fill ( 0 ) ; var n = s . length ; for ( var i = 0 ; i < s . length ; i ++ ) freq [ s [ i ] - 97 ] ++ ; for ( var i = 0 ; i < 26 ; i ++ ) if ( freq [ i ] % 2 == 1 ) return false ; return true ; } var s = " " ; check ( s ) ? document . write ( " " ) : document . write ( " " ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function isValidSubString ( r , K , p ) { var c = 0 ; for ( var i = 0 ; i < r . length ; i ++ ) { if ( r . charCodeAt ( i ) > p ) c ++ ; } if ( c == K ) return true ; else return false ; } function countSubStrings ( s , K , p ) { var l = s . length ; var count = 0 ; for ( var i = 0 ; i < l ; i ++ ) { for ( var j = K ; ( i + j ) <= l ; j ++ ) { var r = s . substring ( i , i + j ) ; if ( isValidSubString ( r , K , p ) ) count ++ ; } } document . write ( count + " " ) ; } var s = " " ; var K = 4 ; var p = 110 ; countSubStrings ( s , K , p ) ;

Accumulator variables: c, count, i, j
Iterator variables: i, j
Javascript program:
function count ( S , X ) { var count = 0 ; var N = S . length ; for ( var i = 0 ; i < N ; ++ i ) { if ( S [ i ] != ' ' ) { for ( var len = 1 ; ( i + len ) <= N ; ++ len ) { if ( parseInt ( S . substring ( i , i + len ) ) > X ) count ++ ; } } } return count ; } var S = " " ; var X = 97 ; document . write ( count ( S , X ) ) ;

Index/key variables: i
Accumulator variables: count
Iterator variables: i, len
Javascript program:
function isBinary ( n ) { while ( n != 0 ) { var temp = n % 10 ; if ( temp != 0 && temp != 1 ) { return false ; } n = parseInt ( n / 10 ) ; } return true ; } function formBinaryStr ( n , a ) { var flag = true ; var s = " " ; for ( i = 0 ; i < n ; i ++ ) { if ( isBinary ( a [ i ] ) ) s += " " + a [ i ] ; else { flag = false ; break ; } } if ( flag ) document . write ( s + " " ) ; else document . write ( " " ) ; } var a = [ 10 , 1 , 0 , 11 , 10 ] ; var N = a . length ; formBinaryStr ( N , a ) ;

Index/key variables: i
Accumulator variables: i, s
Iterator variables: i
Boolean variables: flag
Javascript program:
function fact ( n ) { let result = 1 ; for ( let i = 1 ; i <= n ; i ++ ) result *= i ; return result ; } function getResult ( str , ch ) { let has = new Array ( 26 ) . fill ( null ) ; for ( let i = 0 ; i < str . length ; i ++ ) has [ str . charCodeAt ( i ) - ' ' . charCodeAt ( 0 ) ] ++ ; particular = has [ ch . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] ; if ( particular == 0 ) return 0 ; has [ ch . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] = 0 ; let total = str . length ; total = total - particular + 1 ; let result = fact ( total ) ; for ( let i = 0 ; i < 26 ; i ++ ) { if ( has [ i ] > 1 ) { result = result / fact ( has [ i ] ) ; } } return result ; } let str = " " ; document . write ( getResult ( str , ' ' ) + " " ) ;

Index/key variables: i
Accumulator variables: i, result
Iterator variables: i
Javascript program:
function isAnyNotPalindrome ( s ) { var unique = new Set ( ) ; for ( var i = 0 ; i < s . length ; i ++ ) unique . add ( s [ i ] ) ; if ( unique . size > 1 ) return true ; else return false ; } var s = " " ; if ( isAnyNotPalindrome ( s ) ) document . write ( " " ) ; else document . write ( " " ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function factorial ( n ) { let res = 1 ; for ( let i = 1 ; i <= n ; i ++ ) res = res * i ; return res ; } function count1 ( word ) { let freq = new Array ( 27 ) . fill ( 0 ) ; for ( let i = 0 ; i < 27 ; i ++ ) freq [ i ] = 0 ; let vowel = 0 ; let consonant = 0 ; for ( let i = 0 ; i < word . length ; i ++ ) { freq [ word . charCodeAt ( i ) - 65 ] ++ ; if ( word [ i ] == ' ' word [ i ] == ' ' word [ i ] == ' ' word [ i ] == ' ' word [ i ] == ' ' ) { vowel ++ ; } else consonant ++ ; } vowelArrange = factorial ( vowel ) ; vowelArrange /= factorial ( freq [ 0 ] ) ; vowelArrange /= factorial ( freq [ 4 ] ) ; vowelArrange /= factorial ( freq [ 8 ] ) ; vowelArrange /= factorial ( freq [ 14 ] ) ; vowelArrange /= factorial ( freq [ 20 ] ) ; consonantArrange = factorial ( consonant ) ; for ( let i = 0 ; i < 26 ; i ++ ) { if ( i != 0 && i != 4 && i != 8 && i != 14 && i != 20 ) consonantArrange /= factorial ( freq [ i ] ) ; } let total = vowelArrange * consonantArrange ; return total ; } let word = " " ; let ans = count1 ( word ) ; document . write ( ans ) ;

Index/key variables: i
Accumulator variables: consonant, consonantArrange, i, vowel, vowelArrange
Iterator variables: i
Javascript program:
function productAscii ( str ) { var prod = 1 ; for ( i = 0 ; i < str . length ; i ++ ) { prod *= str . charAt ( i ) . charCodeAt ( 0 ) ; } return prod ; } str = " " ; document . write ( productAscii ( str ) ) ;

Accumulator variables: i, prod
Iterator variables: i
Javascript program:
function check ( s ) { let n = s . length ; var Presum = [ ] ; Presum . push ( parseInt ( s [ 0 ] ) ) ; let i ; for ( i = 1 ; i < n ; i ++ ) { Presum . push ( Presum [ i - 1 ] + parseInt ( s [ i ] ) ) ; } for ( i = 1 ; i <= n - 1 ; i ++ ) { let sum = Presum [ i - 1 ] ; let presum = 0 ; let it = i ; let flag = 0 ; while ( it < n ) { presum += parseInt ( s [ it ] ) ; if ( presum == sum ) { presum = 0 ; flag = 1 ; } else if ( presum > sum ) { break ; } it ++ ; } if ( presum == 0 && it == n && flag == 1 ) { return true ; } } return false ; } var s = " " ; if ( check ( s ) ) document . write ( " " ) ; else document . write ( " " ) ;

Index/key variables: i, it
Accumulator variables: i, it, presum
Iterator variables: i
Javascript program:
function balancedString ( str ) { var count = 0 , i ; var n = str . length ; for ( i = 0 ; i < n ; i ++ ) { if ( str [ i ] == ' ' ) { document . write ( str [ i ] ) ; count ++ ; } else if ( str [ i ] == ' ' && count != 0 ) { document . write ( str [ i ] ) ; count -- ; } else if ( str [ i ] != ' ' ) document . write ( str [ i ] ) ; } if ( count != 0 ) for ( i = 0 ; i < count ; i ++ ) document . write ( " " ) ; } var str = " " ; balancedString ( str ) ;

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Javascript program:
var MAX = 1000000000 ; function minOperation ( s , i , j , count ) { if ( ( i >= s . length && j < 0 ) || ( i == j ) ) return MAX ; if ( s [ i ] == s [ j ] ) return count ; if ( i >= s . length ) return minOperation ( s , i , j - 1 , count + 1 ) ; else if ( j < 0 ) return minOperation ( s , i + 1 , j , count + 1 ) ; else return Math . min ( minOperation ( s , i , j - 1 , count + 1 ) , minOperation ( s , i + 1 , j , count + 1 ) ) ; } var s = " " ; var ans = minOperation ( s , 0 , s . length - 1 , 0 ) ; if ( ans == MAX ) document . write ( - 1 ) ; else document . write ( ans ) ;

Index/key variables: i, j
Javascript program:
function countStrings ( s ) { let sum = 1 ; for ( let i = 0 ; i < s . length ; i ++ ) { if ( i % 2 == 0 && s [ i ] == ' ' ) sum *= 21 ; else if ( s [ i ] == ' ' ) sum *= 5 ; } return sum ; } let str = " " ; document . write ( countStrings ( str ) ) ;

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Javascript program:
function removeDuplicatesFromString ( string ) { let counter = 0 ; let str = string . split ( " " ) ; let i = 0 ; let size = str . length ; let x ; let length = 0 ; while ( i < size ) { x = str [ i ] . charCodeAt ( 0 ) - 97 ; if ( ( counter & ( 1 << x ) ) == 0 ) { str [ length ] = String . fromCharCode ( ' ' . charCodeAt ( 0 ) + x ) ; counter = counter | ( 1 << x ) ; length ++ ; } i ++ ; } return str . join ( " " ) . slice ( 0 , length ) ; } let str = " " ; document . write ( removeDuplicatesFromString ( str ) ) ;

Index/key variables: i
Accumulator variables: i
Javascript program:
function removeDuplicatesFromString ( string ) { let table = new Array ( 256 ) ; for ( let i = 0 ; i < table . length ; i ++ ) table [ i ] = 0 ; let chars = string . split ( " " ) ; let endIndex = 0 ; for ( let i = 0 ; i < chars . length ; i ++ ) { if ( table [ chars [ i ] . charCodeAt ( 0 ) ] == 0 ) { table [ chars [ i ] . charCodeAt ( 0 ) ] = - 1 ; chars [ endIndex ++ ] = chars [ i ] ; } } let ans = " " ; for ( let i = 0 ; i < endIndex ; i ++ ) ans += chars [ i ] return ans ; } let str = " " ; document . write ( removeDuplicatesFromString ( str ) ) ;

Index/key variables: i
Accumulator variables: ans, endIndex, i
Iterator variables: i
Javascript program:
function firstPos ( str , start , end ) { let firstChar = - 1 ; for ( let i = start ; i <= end ; i ++ ) { if ( str [ i ] >= ' ' && str [ i ] <= ' ' ) { firstChar = i ; break ; } } return firstChar ; } function lastPos ( str , start , end ) { let lastChar = - 1 ; for ( let i = start ; i >= end ; i -- ) { if ( str [ i ] >= ' ' && str [ i ] <= ' ' ) { lastChar = i ; break ; } } return lastChar ; } function isPalindrome ( str ) { let firstChar = 0 , lastChar = str . length - 1 ; let ch = true ; for ( let i = 0 ; i < str . length ; i ++ ) { firstChar = firstPos ( str , firstChar , lastChar ) ; lastChar = lastPos ( str , lastChar , firstChar ) ; if ( lastChar < 0 firstChar < 0 ) break ; if ( str [ firstChar ] == str [ lastChar ] ) { firstChar ++ ; lastChar -- ; continue ; } ch = false ; break ; } return ch ; } let str = " " ; if ( isPalindrome ( str ) ) document . write ( " " ) ; else document . write ( " " ) ;

Index/key variables: firstChar, i, lastChar
Accumulator variables: firstChar, i, lastChar
Iterator variables: i
Boolean variables: ch