dhyuti-n/xlcost-variable-roles huggingface dataset:
Javascript program:
function arcIntersection ( S , len ) { var stk = [ ] ; for ( var i = 0 ; i < len ; i ++ ) { stk . push ( S [ i ] ) ; if ( stk . length >= 2 ) { var temp = stk [ stk . length - 1 ] ; stk . pop ( ) ; if ( stk [ stk . length - 1 ] == temp ) { stk . pop ( ) ; } else { stk . push ( temp ) ; } } } if ( stk . length == 0 ) return 1 ; return 0 ; } function countString ( arr , N ) { var count = 0 ; for ( var i = 0 ; i < N ; i ++ ) { var len = arr [ i ] . length ; count += arcIntersection ( arr [ i ] , len ) ; } document . write ( count + " " ) ; } var arr = [ " " , " " , " " ] ; var N = arr . length ; countString ( arr , N ) ;

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Javascript program:
function ConvertequivalentBase8 ( S ) { let mp = new Map ( ) ; mp . set ( " " , ' ' ) ; mp . set ( " " , ' ' ) ; mp . set ( " " , ' ' ) ; mp . set ( " " , ' ' ) ; mp . set ( " " , ' ' ) ; mp . set ( " " , ' ' ) ; mp . set ( " " , ' ' ) ; mp . set ( " " , ' ' ) ; let N = S . length ; if ( N % 3 == 2 ) { S = " " + S ; } else if ( N % 3 == 1 ) { S = " " + S ; } N = S . length ; let oct = " " ; for ( let i = 0 ; i < N ; i += 3 ) { let temp = S . substring ( i , i + 3 ) ; oct += mp . get ( temp ) ; } return oct ; } function binString_div_9 ( S , N ) { let oct = " " ; oct = ConvertequivalentBase8 ( S ) ; let oddSum = 0 ; let evenSum = 0 ; let M = oct . length ; for ( let i = 0 ; i < M ; i += 2 ) oddSum += ( oct [ i ] - ' ' ) ; for ( let i = 1 ; i < M ; i += 2 ) { evenSum += ( oct [ i ] - ' ' ) ; } let Oct_9 = 11 ; if ( Math . abs ( oddSum - evenSum ) % Oct_9 == 0 ) { return " " ; } return " " ; } let S = " " ; let N = S . length ; document . write ( binString_div_9 ( S , N ) ) ;

Index/key variables: i
Accumulator variables: evenSum, i, oct, oddSum
Iterator variables: i
Javascript program:
function min_cost ( S ) { let cost = 0 ; let F = 0 ; let B = 0 ; let count = 0 ; for ( let i in S ) if ( S [ i ] == ' ' ) count ++ ; let n = S . length - count ; if ( n == 1 ) return cost ; for ( let i in S ) { if ( S [ i ] != ' ' ) { if ( B != 0 ) { cost += Math . min ( n - F , F ) * B ; B = 0 ; } F += 1 ; } else { B += 1 ; } } return cost ; } let S = " " ; document . write ( min_cost ( S . split ( ' ' ) ) ) ;

Index/key variables: i
Accumulator variables: B, F, cost, count
Iterator variables: i
Javascript program:
function isVowel ( ch ) { if ( ch == ' ' ch == ' ' ch == ' ' ch == ' ' ch == ' ' ) return true ; else return false ; } function minCost ( S ) { var cA = 0 ; var cE = 0 ; var cI = 0 ; var cO = 0 ; var cU = 0 ; for ( var i = 0 ; i < S . length ; i ++ ) { if ( isVowel ( S [ i ] ) ) { cA += Math . abs ( S . charCodeAt ( i ) - ' ' . charCodeAt ( 0 ) ) ; cE += Math . abs ( S . charCodeAt ( i ) - ' ' . charCodeAt ( 0 ) ) ; cI += Math . abs ( S . charCodeAt ( i ) - ' ' . charCodeAt ( 0 ) ) ; cO += Math . abs ( S . charCodeAt ( i ) - ' ' . charCodeAt ( 0 ) ) ; cU += Math . abs ( S . charCodeAt ( i ) - ' ' . charCodeAt ( 0 ) ) ; } } return Math . min ( Math . min ( Math . min ( Math . min ( cA , cE ) , cI ) , cO ) , cU ) ; } var S = " " ; document . write ( minCost ( S ) ) ;

Index/key variables: i
Accumulator variables: cA, cE, cI, cO, cU, i
Iterator variables: i
Javascript program:
function decode_String ( str , K ) { let ans = " " ; for ( let i = 0 ; i < str . length ; i += K ) ans += str [ i ] ; for ( let i = str . length - ( K - 1 ) ; i < str . length ; i ++ ) ans += str [ i ] ; document . write ( ans ) ; } let K = 3 ; let str = " " ; decode_String ( str , K ) ;

Index/key variables: i
Accumulator variables: ans, i
Iterator variables: i
Javascript program:
function maxVowelSubString ( str , K ) { var N = str . length ; var pref = Array ( N ) ; for ( var i = 0 ; i < N ; i ++ ) { if ( str [ i ] == ' ' str [ i ] == ' ' str [ i ] == ' ' str [ i ] == ' ' str [ i ] == ' ' ) pref [ i ] = 1 ; else pref [ i ] = 0 ; if ( i ) pref [ i ] += pref [ i - 1 ] ; } var maxCount = pref [ K - 1 ] ; var res = str . substring ( 0 , K ) ; for ( var i = K ; i < N ; i ++ ) { var currCount = pref [ i ] - pref [ i - K ] ; if ( currCount > maxCount ) { maxCount = currCount ; res = str . substring ( i - K + 1 , i - 1 ) ; } else if ( currCount == maxCount ) { var temp = str . substring ( i - K + 1 , i + 1 ) ; if ( temp < res ) res = temp ; } } return res ; } var str = " " ; var K = 3 ; document . write ( maxVowelSubString ( str , K ) ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function decodeStr ( str , len ) { var c = Array ( len ) . fill ( " " ) ; var med , pos = 1 , k ; if ( len % 2 == 1 ) med = parseInt ( len / 2 ) ; else med = parseInt ( len / 2 ) - 1 ; c [ med ] = str [ 0 ] ; if ( len % 2 == 0 ) c [ med + 1 ] = str [ 1 ] ; if ( len & 1 ) k = 1 ; else k = 2 ; for ( var i = k ; i < len ; i += 2 ) { c [ med - pos ] = str [ i ] ; if ( len % 2 == 1 ) c [ med + pos ] = str [ i + 1 ] ; else c [ med + pos + 1 ] = str [ i + 1 ] ; pos ++ ; } for ( var i = 0 ; i < len ; i ++ ) { document . write ( c [ i ] ) ; } } var str = " " ; var len = str . length ; decodeStr ( str , len ) ;

Index/key variables: i, med
Accumulator variables: i, pos
Iterator variables: i
Javascript program:
function findCount ( s , L , R ) { var distinct = 0 ; var frequency = Array ( 26 ) . fill ( 0 ) ; for ( var i = L ; i <= R ; i ++ ) { frequency [ s [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] ++ ; } for ( var i = 0 ; i < 26 ; i ++ ) { if ( frequency [ i ] > 0 ) distinct ++ ; } document . write ( distinct + " " ) ; } var s = " " ; var queries = 3 ; var Q = [ [ 0 , 10 ] , [ 15 , 18 ] , [ 12 , 20 ] ] ; for ( var i = 0 ; i < queries ; i ++ ) findCount ( s , Q [ i ] [ 0 ] , Q [ i ] [ 1 ] ) ;

Index/key variables: i
Accumulator variables: distinct, i
Iterator variables: i
Javascript program:
function ReverseComplement ( s , n , k ) { var rev = parseInt ( ( k + 1 ) / 2 ) ; var complement = k - rev ; if ( rev % 2 ) { s = s . split ( ' ' ) . reverse ( ) . join ( ' ' ) ; } if ( complement % 2 ) { for ( var i = 0 ; i < n ; i ++ ) { if ( s [ i ] == ' ' ) s [ i ] = ' ' ; else s [ i ] = ' ' ; } } return s ; } var str = " " ; var k = 5 ; var n = str . length ; document . write ( ReverseComplement ( str , n , k ) ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function repeatingString ( s , n , k ) { if ( n % k != 0 ) { return false ; } var frequency = new Array ( 123 ) ; for ( let i = 0 ; i < 123 ; i ++ ) { frequency [ i ] = 0 ; } for ( let i = 0 ; i < n ; i ++ ) { frequency [ s [ i ] ] ++ ; } var repeat = n / k ; for ( let i = 0 ; i < 123 ; i ++ ) { if ( frequency [ i ] % repeat != 0 ) { return false ; } } return true ; } var s = " " ; var n = s . length ; var k = 3 ; if ( repeatingString ( s , n , k ) ) { console . log ( " " ) ; } else { console . log ( " " ) ; }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function findPhoneNumber ( n ) { let temp = n ; let sum = 0 ; while ( temp != 0 ) { sum += temp % 10 ; temp = Math . floor ( temp / 10 ) ; } if ( sum < 10 ) document . write ( n + " " + sum ) ; else document . write ( n + " " + sum ) ; } let n = 98765432 ; findPhoneNumber ( n ) ;

Accumulator variables: sum
Javascript program:
var maxN = 20 ; var maxM = 64 ; function cntSplits ( s ) { if ( s [ s . length - 1 ] == ' ' ) return 0 ; var c_zero = 0 ; for ( var i = 0 ; i < s . length ; i ++ ) c_zero += ( s [ i ] == ' ' ) ; return Math . pow ( 2 , c_zero - 1 ) ; } var s = " " ; document . write ( cntSplits ( s ) ) ;

Index/key variables: i
Accumulator variables: c_zero, i
Iterator variables: i
Javascript program:
function findNumbers ( s ) { var n = s . length ; var count = 1 ; var result = 0 ; var left = 0 ; var right = 1 ; while ( right < n ) { if ( s [ left ] == s [ right ] ) { count ++ ; } else { result += parseInt ( count * ( count + 1 ) / 2 ) ; left = right ; count = 1 ; } right ++ ; } result += parseInt ( count * ( count + 1 ) / 2 ) ; document . write ( result ) ; } var s = " " ; findNumbers ( s ) ;

Index/key variables: left, right
Accumulator variables: count, result, right
Javascript program:
function isVowel ( ch ) { ch = ch . toUpperCase ( ) ; return ( ch == ' ' ch == ' ' ch == ' ' ch == ' ' ch == ' ' ) ; } function duplicateVowels ( str ) { let t = str . length ; let res = " " ; for ( let i = 0 ; i < t ; i ++ ) { if ( isVowel ( str [ i ] ) ) res += str [ i ] ; res += str [ i ] ; } return res ; } let str = " " ; document . write ( " " + str + " " ) ; let res = duplicateVowels ( str ) ; document . write ( " " + res + " " ) ;

Index/key variables: i
Accumulator variables: i, res
Iterator variables: i
Javascript program:
var MAX = 26 ; function largestSubSeq ( arr , n ) { var count = Array ( MAX ) . fill ( 0 ) ; for ( var i = 0 ; i < n ; i ++ ) { var str = arr [ i ] ; var hash = Array ( MAX ) . fill ( 0 ) ; for ( var j = 0 ; j < str . length ; j ++ ) { hash [ str [ j ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] = true ; } for ( var j = 0 ; j < MAX ; j ++ ) { if ( hash [ j ] ) count [ j ] ++ ; } } return count . reduce ( ( a , b ) => Math . max ( a , b ) ) ; } var arr = [ " " , " " , " " ] ; var n = arr . length ; document . write ( largestSubSeq ( arr , n ) ) ;

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
function isPalindrome ( str ) { let len = str . length ; for ( let i = 0 ; i < len / 2 ; i ++ ) { if ( str [ i ] != str [ len - 1 - i ] ) return false ; } return true ; } function createStringAndCheckPalindrome ( N ) { let sub = " " + N , res_str = " " ; let sum = 0 ; while ( N > 0 ) { let digit = N % 10 ; sum += digit ; N = N / 10 ; } while ( res_str . length < sum ) res_str += sub ; if ( res_str . length > sum ) res_str = res_str . substring ( 0 , sum ) ; if ( isPalindrome ( res_str ) ) return true ; return false ; } let N = 10101 ; if ( createStringAndCheckPalindrome ( N ) ) document . write ( " " ) ; else document . write ( " " ) ;

Index/key variables: i
Accumulator variables: i, res_str, sum
Iterator variables: i
Javascript program:
function minimumLength ( s ) { var maxOcc = 0 , n = s . length ; var arr = Array ( 26 ) . fill ( 0 ) ; for ( var i = 0 ; i < n ; i ++ ) arr [ s [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] ++ ; for ( var i = 0 ; i < 26 ; i ++ ) if ( arr [ i ] > maxOcc ) maxOcc = arr [ i ] ; return ( n - maxOcc ) ; } var str = " " ; document . write ( minimumLength ( str ) ) ;

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

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function removeSpecialCharacter ( str ) { let s = str . split ( " " ) ; let j = 0 ; for ( let i = 0 ; i < s . length ; i ++ ) { if ( ( s [ i ] >= ' ' && s [ i ] <= ' ' ) || ( s [ i ] >= ' ' && s [ i ] <= ' ' ) ) { s [ j ] = s [ i ] ; j ++ ; } } document . write ( ( s ) . join ( " " ) . substring ( 0 , j ) ) ; } let s = " " ; removeSpecialCharacter ( s ) ;

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i
Javascript program:
function findRepeatFirstN2 ( s ) { let p = - 1 , i , j ; for ( i = 0 ; i < s . length ; i ++ ) { for ( j = i + 1 ; j < s . length ; j ++ ) { if ( s [ i ] == s [ j ] ) { p = i ; break ; } } if ( p != - 1 ) break ; } return p ; } let str = " " ; let pos = findRepeatFirstN2 ( str ) ; if ( pos == - 1 ) document . write ( " " ) ; else document . write ( str [ pos ] ) ;

Index/key variables: i, j, pos
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
function possibleStrings ( n , r , b , g ) { let fact = new Array ( n + 1 ) ; fact [ 0 ] = 1 ; for ( let i = 1 ; i <= n ; i ++ ) fact [ i ] = fact [ i - 1 ] * i ; let left = n - ( r + g + b ) ; let sum = 0 ; for ( let i = 0 ; i <= left ; i ++ ) { for ( let j = 0 ; j <= left - i ; j ++ ) { let k = left - ( i + j ) ; sum = sum + fact [ n ] / ( fact [ i + r ] * fact [ j + b ] * fact [ k + g ] ) ; } } return sum ; } let n = 4 , r = 2 ; let b = 0 , g = 1 ; document . write ( possibleStrings ( n , r , b , g ) ) ;

Index/key variables: i, n
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
function remAnagram ( str1 , str2 ) { var count1 = Array . from ( { length : 26 } , ( _ , i ) => 0 ) ; var count2 = Array . from ( { length : 26 } , ( _ , i ) => 0 ) ; for ( i = 0 ; i < str1 . length ; i ++ ) count1 [ str1 . charAt ( i ) . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] ++ ; for ( i = 0 ; i < str2 . length ; i ++ ) count2 [ str2 . charAt ( i ) . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] ++ ; var result = 0 ; for ( i = 0 ; i < 26 ; i ++ ) result += Math . abs ( count1 [ i ] - count2 [ i ] ) ; return result ; } var str1 = " " , str2 = " " ; document . write ( remAnagram ( str1 , str2 ) ) ;

Index/key variables: i
Accumulator variables: i, result
Iterator variables: i
Javascript program:
let CHARS = 26 ; function isValidString ( str ) { let freq = new Array ( CHARS ) ; for ( let i = 0 ; i < CHARS ; i ++ ) { freq [ i ] = 0 ; } for ( let i = 0 ; i < str . length ; i ++ ) { freq [ str [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] ++ ; } let i , freq1 = 0 , count_freq1 = 0 ; for ( i = 0 ; i < CHARS ; i ++ ) { if ( freq [ i ] != 0 ) { freq1 = freq [ i ] ; count_freq1 = 1 ; break ; } } let j , freq2 = 0 , count_freq2 = 0 ; for ( j = i + 1 ; j < CHARS ; j ++ ) { if ( freq [ j ] != 0 ) { if ( freq [ j ] == freq1 ) { count_freq1 ++ ; } else { count_freq2 = 1 ; freq2 = freq [ j ] ; break ; } } } for ( let k = j + 1 ; k < CHARS ; k ++ ) { if ( freq [ k ] != 0 ) { if ( freq [ k ] == freq1 ) { count_freq1 ++ ; } if ( freq [ k ] == freq2 ) { count_freq2 ++ ; { return false ; } } if ( count_freq1 > 1 && count_freq2 > 1 ) { return false ; } } return true ; } let str = " " ; if ( isValidString ( str ) ) { document . write ( " " ) ; } else { document . write ( " " ) ; }

Index/key variables: i, j, k
Accumulator variables: count_freq1, count_freq2, i, j, k
Iterator variables: i, j, k
Javascript program:
function checkForVariation ( str ) { if ( str == null str . length == 0 ) { return true ; } let map = new Map ( ) ; for ( let i = 0 ; i < str . length ; i ++ ) { if ( ! map . has ( str [ i ] ) ) map . set ( str [ i ] , 0 ) ; map . set ( str [ i ] , map . get ( str [ i ] ) + 1 ) ; } let first = true , second = true ; let val1 = 0 , val2 = 0 ; let countOfVal1 = 0 , countOfVal2 = 0 ; for ( let [ key , value ] of map . entries ( ) ) { let i = value ; if ( first ) { val1 = i ; first = false ; countOfVal1 ++ ; continue ; } if ( i == val1 ) { countOfVal1 ++ ; continue ; } if ( second ) { val2 = i ; countOfVal2 ++ ; second = false ; continue ; } if ( i == val2 ) { countOfVal2 ++ ; continue ; } return false ; } if ( countOfVal1 > 1 && countOfVal2 > 1 ) { return false ; } else { return true ; } } document . write ( checkForVariation ( " " ) ) ;

Index/key variables: i
Accumulator variables: countOfVal1, countOfVal2, i
Iterator variables: i
Boolean variables: first, second
Javascript program:
function countCompletePairs ( set1 , set2 , n , m ) { let result = 0 ; for ( let i = 0 ; i < n ; i ++ ) { for ( let j = 0 ; j < m ; j ++ ) { let concat = set1 [ i ] + set2 [ j ] ; let frequency = new Array ( 26 ) ; for ( let i = 0 ; i < 26 ; i ++ ) { frequency [ i ] = 0 ; } for ( let k = 0 ; k < concat . length ; k ++ ) { frequency [ concat [ k ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] ++ ; } let k ; for ( k = 0 ; k < 26 ; k ++ ) { if ( frequency [ k ] < 1 ) { break ; } } if ( k == 26 ) { result ++ ; } } } return result ; } let set1 = [ " " , " " , " " , " " ] ; let set2 = [ " " , " " , " " ] let n = set1 . length ; let m = set2 . length ; document . write ( countCompletePairs ( set1 , set2 , n , m ) ) ;

Index/key variables: i, j, k
Accumulator variables: i, j, k, result
Iterator variables: i, j, k
Javascript program:
function countCompletePairs ( set1 , set2 , n , m ) { let result = 0 ; let con_s1 = new Array ( n ) ; let con_s2 = new Array ( m ) ; for ( let i = 0 ; i < n ; i ++ ) { con_s1 [ i ] = 0 ; for ( let j = 0 ; j < set1 [ i ] . length ; j ++ ) { con_s1 [ i ] = con_s1 [ i ] | ( 1 << ( set1 [ i ] [ j ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ) ) ; } } for ( let i = 0 ; i < m ; i ++ ) { con_s2 [ i ] = 0 ; for ( let j = 0 ; j < set2 [ i ] . length ; j ++ ) { con_s2 [ i ] = con_s2 [ i ] | ( 1 << ( set2 [ i ] [ j ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ) ) ; } } let complete = ( 1 << 26 ) - 1 ; for ( let i = 0 ; i < n ; i ++ ) { for ( let j = 0 ; j < m ; j ++ ) { if ( ( con_s1 [ i ] con_s2 [ j ] ) == complete ) { result ++ ; } } } return result ; } let set1 = [ " " , " " , " " , " " ] ; let set2 = [ " " , " " , " " ] let n = set1 . length ; let m = set2 . length ; document . write ( countCompletePairs ( set1 , set2 , n , m ) ) ;

Index/key variables: i, j
Accumulator variables: i, j, result
Iterator variables: i, j
Javascript program:
function encodeString ( str ) { let map = new Map ( ) ; let res = " " ; let i = 0 ; let ch ; for ( let j = 0 ; j < str . length ; j ++ ) { ch = str [ j ] ; if ( ! map . has ( ch ) ) map . set ( ch , i ++ ) ; res += map . get ( ch ) ; } return res ; } function findMatchedWords ( dict , pattern ) { let len = pattern . length ; let hash = encodeString ( pattern ) ; for ( let word = 0 ; word < dict . length ; word ++ ) { if ( dict [ word ] . length == len && encodeString ( dict [ word ] ) == ( hash ) ) document . write ( dict [ word ] + " " ) ; } } let dict = [ " " , " " , " " , " " ] ; let pattern = " " ; findMatchedWords ( dict , pattern ) ;

Index/key variables: j, word
Accumulator variables: i, j, res, word
Iterator variables: j, word
Javascript program:
function check ( pattern , word ) { if ( pattern . length != word . length ) return false ; let ch = new Array ( 128 ) ; for ( let i = 0 ; i < 128 ; i ++ ) { ch [ i ] = 0 ; } let Len = word . length ; for ( let i = 0 ; i < Len ; i ++ ) { if ( ch [ pattern [ i ] . charCodeAt ( 0 ) ] == 0 ) { ch [ pattern [ i ] . charCodeAt ( 0 ) ] = word [ i ] ; } else if ( ch [ pattern [ i ] . charCodeAt ( 0 ) ] != word [ i ] ) { return false ; } } return true ; } function findMatchedWords ( dict , pattern ) { let Len = pattern . length ; let result = " " ; for ( let word of dict . values ( ) ) { if ( check ( pattern , word ) ) { result = word + " " + result ; } } document . write ( result ) ; } let dict = new Set ( ) ; dict . add ( " " ) ; dict . add ( " " ) ; dict . add ( " " ) ; dict . add ( " " ) ; let pattern = " " ; findMatchedWords ( dict , pattern ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i, word
Javascript program:
function countWords ( str ) { if ( str == null str . length == 0 ) return 0 ; let wordCount = 0 ; let isWord = false ; let endOfLine = str . length - 1 ; let ch = str . split ( " " ) ; for ( let i = 0 ; i < ch . length ; i ++ ) { if ( isLetter ( ch [ i ] ) && i != endOfLine ) isWord = true ; else if ( ! isLetter ( ch [ i ] ) && isWord ) { wordCount ++ ; isWord = false ; } else if ( isLetter ( ch [ i ] ) && i == endOfLine ) wordCount ++ ; } return wordCount ; } function isLetter ( c ) { return c . toLowerCase ( ) != c . toUpperCase ( ) ; } let str = " " ; document . write ( " " + countWords ( str ) ) ;

Index/key variables: i
Accumulator variables: i, wordCount
Iterator variables: i
Boolean variables: isWord
Javascript program:
function RevString ( s , l ) { if ( l % 2 == 0 ) { let j = parseInt ( l / 2 , 10 ) ; while ( j <= l - 1 ) { let temp ; temp = s [ l - j - 1 ] ; s [ l - j - 1 ] = s [ j ] ; s [ j ] = temp ; j += 1 ; } } else { let j = parseInt ( ( l / 2 ) , 10 ) + 1 ; while ( j <= l - 1 ) { let temp ; temp = s [ l - j - 1 ] ; s [ l - j - 1 ] = s [ j ] ; s [ j ] = temp ; j += 1 ; } } let S = s [ 0 ] ; for ( let i = 1 ; i < 9 ; i ++ ) { S = S + " " + s [ i ] ; } return S ; } let s = " " " " ; let words = [ " " , " " , " " , " " , " " , " " , " " , " " , " " ] ; document . write ( RevString ( words , 9 ) ) ;

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i
Javascript program:
function printPath ( res , nThNode , kThNode ) { if ( kThNode > nThNode ) return ; res . push ( kThNode ) ; for ( var i = 0 ; i < res . length ; i ++ ) document . write ( res [ i ] + " " ) ; document . write ( " " ) ; printPath ( res , nThNode , kThNode * 2 ) ; printPath ( res , nThNode , kThNode * 2 + 1 ) ; res . pop ( ) } function printPathToCoverAllNodeUtil ( nThNode ) { var res = [ ] ; printPath ( res , nThNode , 1 ) ; } var nThNode = 7 ; printPathToCoverAllNodeUtil ( nThNode ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function getMid ( s , e ) { return s + Math . floor ( ( e - s ) / 2 ) ; } function isArmstrong ( x ) { let n = ( x ) . toString ( ) . length ; let sum1 = 0 ; let temp = x ; while ( temp > 0 ) { let digit = temp % 10 ; sum1 += Math . pow ( digit , n ) ; temp = Math . floor ( temp / 10 ) ; } if ( sum1 == x ) return true ; return false ; } function MaxUtil ( st , ss , se , l , r , node ) { if ( l <= ss && r >= se ) return st [ node ] ; if ( se < l ss > r ) return - 1 ; let mid = getMid ( ss , se ) ; return Math . max ( MaxUtil ( st , ss , mid , l , r , 2 * node ) , MaxUtil ( st , mid + 1 , se , l , r , 2 * node + 1 ) ) ; } function updateValue ( arr , st , ss , se , index , value , node ) { if ( index < ss index > se ) { document . write ( " " + " " ) ; return ; } if ( ss == se ) { arr [ index ] = value ; if ( isArmstrong ( value ) ) st [ node ] = value ; else st [ node ] = - 1 ; } else { let mid = getMid ( ss , se ) ; if ( index >= ss && index <= mid ) updateValue ( arr , st , ss , mid , index , value , 2 * node ) ; else updateValue ( arr , st , mid + 1 , se , index , value , 2 * node + 1 ) ; st [ node ] = Math . max ( st [ 2 * node + 1 ] , st [ 2 * node + 2 ] ) ; } return ; } function getMax ( st , n , l , r ) { if ( l < 0 r > n - 1 l > r ) { document . write ( " " ) ; return - 1 ; } return MaxUtil ( st , 0 , n - 1 , l , r , 0 ) ; } function constructSTUtil ( arr , ss , se , st , si ) { if ( ss == se ) { if ( isArmstrong ( arr [ ss ] ) ) st [ si ] = arr [ ss ] ; else st [ si ] = - 1 ; return st [ si ] ; } let mid = getMid ( ss , se ) ; st [ si ] = Math . max ( constructSTUtil ( arr , ss , mid , st , si * 2 ) , constructSTUtil ( arr , mid + 1 , se , st , si * 2 + 1 ) ) ; return st [ si ] ; } function constructST ( arr , n ) { let x = ( Math . ceil ( Math . log ( n ) ) ) ; let max_size = 2 * Math . pow ( 2 , x ) - 1 ; let st = new Array ( max_size ) ; constructSTUtil ( arr , 0 , n - 1 , st , 0 ) ; return st ; } let arr = [ 192 , 113 , 535 , 7 , 19 , 111 ] ; let n = arr . length ; let st = constructST ( arr , n ) ; document . write ( " " + " " + getMax ( st , n , 1 , 3 ) + " " ) ; updateValue ( arr , st , 0 , n - 1 , 1 , 153 , 0 ) ; document . write ( " " + " " + getMax ( st , n , 1 , 3 ) + " " ) ;

Index/key variables: index, node, si, ss
Accumulator variables: sum1