dhyuti-n/xlcost-variable-roles huggingface dataset:
Javascript program:
let MAX = 256 ; function fact ( n ) { let res = 1 ; for ( let i = 2 ; i <= n ; i ++ ) res = res * i ; return res ; } function countPalinPermutations ( str ) { let n = str . length ; let freq = new Array ( MAX ) ; freq . fill ( 0 ) ; for ( let i = 0 ; i < n ; i ++ ) freq [ str [ i ] . charCodeAt ( ) ] ++ ; let res = fact ( n / 2 ) ; let oddFreq = false ; for ( let i = 0 ; i < MAX ; i ++ ) { let half = freq [ i ] / 2 ; if ( freq [ i ] % 2 != 0 ) { if ( oddFreq == true ) return 0 ; oddFreq = true ; } res = res / fact ( half ) ; } return res ; } let str = " " ; document . write ( countPalinPermutations ( str ) ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Boolean variables: oddFreq
Javascript program:
function isVowel ( ch ) { return ( ch === " " ch === " " ch === " " ch === " " ch === " " ) ; } function isCons ( ch ) { return ( ch !== " " && ch !== " " && ch !== " " && ch !== " " && ch !== " " ) ; } function countSpecial ( str ) { var len = str . length ; if ( len == 0 ) return 0 ; var co = new Array ( len + 1 ) . fill ( 0 ) ; var vo = new Array ( len + 1 ) . fill ( 0 ) ; if ( isCons ( str [ len - 1 ] ) === true ) co [ len - 1 ] = 1 ; else vo [ len - 1 ] = 1 ; for ( var i = len - 2 ; i >= 0 ; i -- ) { if ( isCons ( str [ i ] ) === true ) { co [ i ] = co [ i + 1 ] + 1 ; vo [ i ] = vo [ i + 1 ] ; } else { co [ i ] = co [ i + 1 ] ; vo [ i ] = vo [ i + 1 ] + 1 ; } } var ans = 0 ; for ( var i = 0 ; i < len ; i ++ ) { if ( isVowel ( str [ i ] ) ) ans = ans + co [ i + 1 ] ; else ans = ans + vo [ i + 1 ] ; } return parseInt ( ans ) ; } var str = " " ; document . write ( countSpecial ( str . split ( " " ) ) ) ;

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

Index/key variables: i
Iterator variables: i
Javascript program:
function evenDecimalValue ( str , n ) { let result = 0 ; for ( let i = 0 ; i < n ; i ++ ) { if ( str [ i ] == ' ' ) { result += ( n - i ) ; } } return result ; } let str = " " ; let n = 5 ; document . write ( evenDecimalValue ( str , n ) ) ;

Index/key variables: i
Accumulator variables: i, result
Iterator variables: i
Javascript program:
function countSubstr ( s ) { let n = s . length ; let auxArr = new Array ( n ) ; if ( s [ 0 ] == ' ' ) auxArr [ 0 ] = 1 ; for ( let i = 1 ; i < n ; i ++ ) { if ( s [ i ] == ' ' ) auxArr [ i ] = auxArr [ i - 1 ] + 1 ; else auxArr [ i ] = auxArr [ i - 1 ] ; } let count = 0 ; for ( let i = n - 1 ; i >= 0 ; i -- ) if ( s [ i ] == ' ' ) count += auxArr [ i ] ; return count ; } let s = " " ; document . write ( countSubstr ( s ) ) ;

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Javascript program:
let MAX = 256 ; function canMakeStr2 ( str1 , str2 ) { let count = new Array ( MAX ) ; count . fill ( 0 ) ; for ( let i = 0 ; i < str1 . length ; i ++ ) count [ str1 [ i ] ] ++ ; for ( let i = 0 ; i < str2 . length ; i ++ ) { if ( count [ str2 [ i ] ] == 0 ) return false ; count [ str2 [ i ] ] -- ; } return true ; } let str1 = " " ; let str2 = " " ; if ( canMakeStr2 ( str1 , str2 ) ) document . write ( " " ) ; else document . write ( " " ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function finalPosition ( move ) { let l = move . length ; let countUp = 0 , countDown = 0 ; let countLeft = 0 , countRight = 0 ; for ( let i = 0 ; i < l ; i ++ ) { if ( move [ i ] == ' ' ) countUp ++ ; else if ( move [ i ] == ' ' ) countDown ++ ; else if ( move [ i ] == ' ' ) countLeft ++ ; else if ( move [ i ] == ' ' ) countRight ++ ; } document . write ( " " + ( countRight - countLeft ) + " " + ( countUp - countDown ) + " " ) ; } let move = " " ; finalPosition ( move ) ;

Index/key variables: i
Accumulator variables: countDown, countLeft, countRight, countUp, i
Iterator variables: i
Javascript program:
function maxbalancedprefix ( str , n ) { var sum = 0 ; var maxi = 0 ; for ( var i = 0 ; i < n ; i ++ ) { if ( str [ i ] == ' ' ) sum += 1 ; else sum -= 1 ; if ( sum < 0 ) break ; if ( sum == 0 ) maxi = i + 1 ; } return maxi ; } var str = " " ; var n = str . length ; document . write ( maxbalancedprefix ( str , n ) ) ;

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Javascript program:
function cost ( str ) { let len = str . length ; let res = 0 ; for ( let i = 0 , j = len - 1 ; i < j ; i ++ , j -- ) { if ( str [ i ] != str [ j ] ) { res += Math . min ( str [ i ] . charCodeAt ( ) , str [ j ] . charCodeAt ( ) ) - ' ' . charCodeAt ( ) + 1 ; } } return res ; } let str = " " ; document . write ( cost ( str ) ) ;

Index/key variables: i, j
Accumulator variables: i, j, res
Iterator variables: i
Javascript program:
function isVowel ( c ) { return ( c == ' ' c == ' ' c == ' ' c == ' ' c == ' ' c == ' ' c == ' ' c == ' ' c == ' ' c == ' ' ) ; } function pigLatin ( s ) { let len = s . length ; let index = - 1 ; for ( let i = 0 ; i < len ; i ++ ) { if ( isVowel ( s [ i ] ) ) { index = i ; break ; } } if ( index == - 1 ) return " " ; return s . substring ( index ) + s . substring ( 0 , index ) + " " ; } str = pigLatin ( " " ) ; if ( str == " " ) document . write ( " " + " " + " " ) ; else document . write ( str ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
let MAX_CHAR = 256 ; function isPresent ( s , q ) { let freq = new Array ( MAX_CHAR ) ; freq . fill ( 0 ) ; for ( let i = 0 ; i < s . length ; i ++ ) freq [ s [ i ] ] ++ ; for ( let i = 0 ; i < q . length ; i ++ ) { freq [ q [ i ] ] -- ; if ( freq [ q [ i ] ] < 0 ) return false ; } return true ; } let s = " " ; let q = " " ; if ( isPresent ( s , q ) ) document . write ( " " ) ; else document . write ( " " ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function countReduce ( str ) { let n = str . length ; let res = 0 ; for ( let i = 0 ; i < parseInt ( n / 2 , 10 ) ; i ++ ) res += Math . abs ( str [ i ] . charCodeAt ( ) - str [ n - i - 1 ] . charCodeAt ( ) ) ; return res ; } let str = " " ; document . write ( countReduce ( str ) ) ;

Index/key variables: i
Accumulator variables: i, res
Iterator variables: i
Javascript program:
function calculate ( s ) { let ans = 6 ; for ( let i = 0 ; i < 10 ; ++ i ) { for ( let j = 0 ; j < 10 ; ++ j ) { for ( let k = 0 ; k < 10 ; ++ k ) { for ( let l = 0 ; l < 10 ; ++ l ) { for ( let m = 0 ; m < 10 ; ++ m ) { for ( let n = 0 ; n < 10 ; ++ n ) { if ( i + j + k == l + m + n ) { let c = 0 ; if ( i != s [ 0 ] - ' ' ) c ++ ; if ( j != s [ 1 ] - ' ' ) c ++ ; if ( k != s [ 2 ] - ' ' ) c ++ ; if ( l != s [ 3 ] - ' ' ) c ++ ; if ( m != s [ 4 ] - ' ' ) c ++ ; if ( n != s [ 5 ] - ' ' ) c ++ ; if ( c < ans ) ans = c ; } } } } } } } return ans ; } let s = " " ; document . write ( calculate ( s ) ) ;

Accumulator variables: c
Iterator variables: i, j, k, l, m, n
Javascript program:
function makeAndCheckString ( words , str ) { let n = words . length ; let first = false , second = false ; for ( let i = 0 ; i < n ; i ++ ) { if ( words [ i ] == str ) return true ; if ( str [ 0 ] == words [ i ] [ 1 ] ) first = true ; if ( str [ 1 ] == words [ i ] [ 0 ] ) second = true ; if ( first && second ) return true ; } return false ; } let str = " " ; let words = [ " " , " " , " " , " " ] ; if ( makeAndCheckString ( words , str ) ) document . write ( " " ) ; else document . write ( " " ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Boolean variables: first, second
Javascript program:
function getBinaryRep ( N , num_of_bits ) { let r = " " ; num_of_bits -- ; while ( num_of_bits >= 0 ) { if ( ( N & ( 1 << num_of_bits ) ) != 0 ) r += " " ; else r += " " ; num_of_bits -- ; } return r ; } function NBitBinary ( N ) { let r = [ ] ; let first = 1 << ( N - 1 ) ; let last = first * 2 ; for ( let i = last - 1 ; i >= first ; -- i ) { let zero_cnt = 0 ; let one_cnt = 0 ; let t = i ; let num_of_bits = 0 ; while ( t > 0 ) { if ( ( t & 1 ) != 0 ) one_cnt ++ ; else zero_cnt ++ ; num_of_bits ++ ; t = t >> 1 ; } if ( one_cnt >= zero_cnt ) { let all_prefix_match = true ; let msk = ( 1 << num_of_bits ) - 2 ; let prefix_shift = 1 ; while ( msk > 0 ) { let prefix = ( msk & i ) >> prefix_shift ; let prefix_one_cnt = 0 ; let prefix_zero_cnt = 0 ; while ( prefix > 0 ) { if ( ( prefix & 1 ) != 0 ) prefix_one_cnt ++ ; else prefix_zero_cnt ++ ; prefix = prefix >> 1 ; } if ( prefix_zero_cnt > prefix_one_cnt ) { all_prefix_match = false ; break ; } prefix_shift ++ ; msk = msk & ( msk << 1 ) ; } if ( all_prefix_match ) { r . push ( getBinaryRep ( i , num_of_bits ) ) ; } } } return r ; } let n = 4 ; let results = NBitBinary ( n ) ; for ( let i = 0 ; i < results . length ; ++ i ) document . write ( results [ i ] + " " ) ; document . write ( " " ) ;

Index/key variables: i
Accumulator variables: num_of_bits, one_cnt, prefix_one_cnt, prefix_shift, prefix_zero_cnt, r, zero_cnt
Iterator variables: i
Boolean variables: all_prefix_match
Javascript program:
function findWinner ( votes ) { let map = new Map ( ) ; for ( let i = 0 ; i < votes . length ; i ++ ) { if ( map . has ( votes [ i ] ) ) { map . set ( votes [ i ] , map . get ( votes [ i ] ) + 1 ) ; } else map . set ( votes [ i ] , 1 ) ; } let maxValueInMap = 0 ; let winner = " " ; for ( let [ key , value ] of map . entries ( ) ) { let Key = key ; let val = value ; if ( val > maxValueInMap ) { maxValueInMap = val ; winner = key ; } else if ( val == maxValueInMap && winner > Key ) winner = Key ; } document . write ( winner ) ; } let votes = [ " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " ] ; findWinner ( votes ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function checkLuhn ( cardNo ) { let nDigits = cardNo . length ; let nSum = 0 ; let isSecond = false ; for ( let i = nDigits - 1 ; i >= 0 ; i -- ) { let d = cardNo [ i ] . charCodeAt ( ) - ' ' . charCodeAt ( ) ; if ( isSecond == true ) d = d * 2 ; nSum += parseInt ( d / 10 , 10 ) ; nSum += d % 10 ; isSecond = ! isSecond ; } return ( nSum % 10 == 0 ) ; } let cardNo = " " ; if ( checkLuhn ( cardNo ) ) document . write ( " " ) ; else document . write ( " " ) ;

Index/key variables: i
Accumulator variables: i, nSum
Iterator variables: i
Boolean variables: isSecond
Javascript program:
let MAX_CHAR = 26 ; function distributingBalls ( k , n , str ) { let a = new Array ( MAX_CHAR ) ; a . fill ( 0 ) ; for ( let i = 0 ; i < n ; i ++ ) { a [ str [ i ] . charCodeAt ( ) - ' ' . charCodeAt ( ) ] ++ ; } for ( let i = 0 ; i < MAX_CHAR ; i ++ ) if ( a [ i ] > k ) return false ; return true ; } let n = 6 , k = 3 ; let str = " " ; if ( distributingBalls ( k , n , str ) ) document . write ( " " ) ; else document . write ( " " ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function isVowel ( x ) { return ( x == ' ' x == ' ' x == ' ' x == ' ' x == ' ' ) ; } function findSubstring ( str ) { let hash = new Set ( ) ; let n = str . length ; for ( let i = 0 ; i < n ; i ++ ) { for ( let j = i ; j < n ; j ++ ) { if ( isVowel ( str [ j ] ) == false ) break ; hash . add ( str [ j ] ) ; if ( hash . size == 5 ) document . write ( str . substring ( i , j + 1 ) + " " ) ; } hash . clear ( ) ; } } let str = " " ; findSubstring ( str ) ;

Index/key variables: j
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
function check ( list , s ) { let n = list . length ; if ( n == 0 ) { return false ; } for ( let i = 0 ; i < n ; i ++ ) { if ( list [ i ] . length != s . length ) { continue ; } let diff = false ; for ( let j = 0 ; j < list [ i ] . length ; j ++ ) { if ( list [ i ] [ j ] != s [ j ] ) { if ( ! diff ) { diff = true ; } else { diff = false ; break ; } } } if ( diff ) { return true ; } } return false ; } let s = [ ] ; s . push ( " " ) ; s . push ( " " ) ; s . push ( " " ) ; s . push ( " " ) ; s . push ( " " ) ; document . write ( check ( s , " " ) == true ? 1 : 0 ) ;

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Boolean variables: diff
Javascript program:
function sentencePalindrome ( str ) { let l = 0 ; let h = str . length - 1 ; str = str . toLowerCase ( ) ; while ( l <= h ) { let getAtl = str [ l ] ; let getAth = str [ h ] ; if ( ! ( getAtl >= ' ' && getAtl <= ' ' ) ) l ++ ; else if ( ! ( getAth >= ' ' && getAth <= ' ' ) ) h -- ; else if ( getAtl == getAth ) { l ++ ; h -- ; } else return false ; } return true ; } let str = " " ; if ( sentencePalindrome ( str ) ) document . write ( " " ) ; else document . write ( " " + " " + " " ) ;

Index/key variables: h, l
Accumulator variables: h, l
Javascript program:
function xorZero ( s ) { let one_count = 0 , zero_count = 0 ; let n = s . length ; for ( let i = 0 ; i < n ; i ++ ) if ( s [ i ] == ' ' ) one_count ++ ; else zero_count ++ ; if ( one_count % 2 == 0 ) return zero_count ; return one_count ; } let s = " " ; document . write ( xorZero ( s ) ) ;

Index/key variables: i
Accumulator variables: i, one_count, zero_count
Iterator variables: i
Javascript program:
function encoder ( key ) { let encoded = " " ; let arr = new Array ( 26 ) ; for ( let i = 0 ; i < 26 ; i ++ ) { arr [ i ] = false ; } for ( let i = 0 ; i < key . length ; i ++ ) { if ( key [ i ] . charCodeAt ( 0 ) >= ' ' . charCodeAt ( 0 ) && key [ i ] . charCodeAt ( 0 ) <= ' ' . charCodeAt ( 0 ) ) { if ( arr [ key [ i ] . charCodeAt ( 0 ) - 65 ] == false ) { encoded += ( key [ i ] ) ; arr [ key [ i ] . charCodeAt ( 0 ) - 65 ] = true ; } } else if ( key [ i ] . charCodeAt ( 0 ) >= ' ' . charCodeAt ( 0 ) && key [ i ] . charCodeAt ( 0 ) <= ' ' . charCodeAt ( 0 ) ) { if ( arr [ key [ i ] . charCodeAt ( 0 ) - 97 ] == false ) { encoded += String . fromCharCode ( key [ i ] . charCodeAt ( 0 ) - 32 ) ; arr [ key [ i ] . charCodeAt ( 0 ) - 97 ] = true ; } } } for ( let i = 0 ; i < 26 ; i ++ ) { if ( arr [ i ] == false ) { arr [ i ] = true ; encoded += String . fromCharCode ( i + 65 ) ; } } return encoded ; } function cipheredIt ( msg , encoded ) { let cipher = " " ; for ( let i = 0 ; i < msg . length ; i ++ ) { if ( msg [ i ] >= ' ' && msg [ i ] <= ' ' ) { let pos = msg [ i ] . charCodeAt ( 0 ) - 97 ; cipher += encoded [ pos ] ; } else if ( msg [ i ] >= ' ' && msg [ i ] <= ' ' ) { let pos = msg [ i ] . charCodeAt ( 0 ) - 65 ; cipher += encoded [ pos ] ; } else { cipher += msg [ i ] ; } } return cipher ; } let key ; key = " " ; document . write ( " " + key + " " ) ; let encoded = encoder ( key . split ( " " ) ) ; let message = " " ; document . write ( " " + message + " " ) ; document . write ( " " + cipheredIt ( message , encoded ) ) ;

Index/key variables: i, pos
Accumulator variables: cipher, encoded, i
Iterator variables: i
Javascript program:
let MAX_CHAR = 26 ; function checkCorrectOrNot ( s ) { let count = new Array ( MAX_CHAR ) ; for ( let i = 0 ; i < count . length ; i ++ ) { count [ i ] = 0 ; } let n = s . length ; if ( n == 1 ) return true ; for ( let i = 0 , j = n - 1 ; i < j ; i ++ , j -- ) { count [ s [ i ] - ' ' ] ++ ; count [ s [ j ] - ' ' ] -- ; } for ( let i = 0 ; i < MAX_CHAR ; i ++ ) if ( count [ i ] != 0 ) return false ; return true ; } let s = " " ; if ( checkCorrectOrNot ( s ) ) document . write ( " " ) ; else document . write ( " " ) ;

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i
Javascript program:
function checkString ( s ) { let len = s . length ; let first = 0 ; for ( let i = 0 ; i < len ; i ++ ) { if ( s [ i ] == ' ' ) { first = i ; break ; } } let last = 0 ; for ( let i = len - 1 ; i >= 0 ; i -- ) { if ( s [ i ] == ' ' ) { last = i ; break ; } } for ( let i = first ; i <= last ; i ++ ) if ( s [ i ] == ' ' ) return false ; return true ; } let s = " " ; document . write ( checkString ( s ) ? " " : " " ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function printAllSubStrings ( s , n ) { for ( let i = 0 ; i < n ; i ++ ) { let temp = new Array ( n - i + 1 ) ; let tempindex = 0 ; for ( let j = i ; j < n ; j ++ ) { temp [ tempindex ++ ] = s [ j ] ; temp [ tempindex ] = ' \0 ' ; document . write ( temp . join ( " " ) + " " ) ; } } } let s = " " ; printAllSubStrings ( s , s . length ) ;

Index/key variables: j, tempindex
Accumulator variables: i, j, tempindex
Iterator variables: i, j
Javascript program:
function preserveSpace ( str ) { let n = str . length ; let start = 0 ; let end = n - 1 ; let Str = str . split ( ' ' ) ; while ( start < end ) { if ( Str [ start ] == ' ' ) { start ++ ; continue ; } else if ( Str [ end ] == ' ' ) { end -- ; continue ; } else { let temp = Str [ start ] ; Str [ start ] = Str [ end ] ; Str [ end ] = temp ; start ++ ; end -- ; } } document . write ( Str . join ( " " ) ) ; } let str = " " ; preserveSpace ( str ) ;

Index/key variables: end, start
Accumulator variables: end, start
Javascript program:
function amendSentence ( sstr ) { let str = sstr . split ( ' ' ) ; for ( let i = 0 ; i < str . length ; i ++ ) { if ( str [ i ] . charCodeAt ( ) >= ' ' . charCodeAt ( ) && str [ i ] . charCodeAt ( ) <= ' ' . charCodeAt ( ) ) { str [ i ] = String . fromCharCode ( str [ i ] . charCodeAt ( ) + 32 ) ; if ( i != 0 ) document . write ( " " ) ; document . write ( str [ i ] ) ; } else document . write ( str [ i ] ) ; } } let str = " " ; amendSentence ( str ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function repeat ( s , n ) { let s1 = s ; for ( let i = 1 ; i < n ; i ++ ) return s ; } let s = " " ; let n = 3 ; document . write ( repeat ( s , n ) ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
let MAX_CHAR = 26 ; function factorial ( n ) { let fact = 1 ; for ( let i = 2 ; i <= n ; i ++ ) fact = fact * i ; return fact ; } function countDistinctPermutations ( str ) { let length = str . length ; let freq = new Array ( MAX_CHAR ) ; freq . fill ( 0 ) ; for ( let i = 0 ; i < length ; i ++ ) if ( str [ i ] . charCodeAt ( ) >= ' ' . charCodeAt ( ) ) freq [ str [ i ] . charCodeAt ( ) - ' ' . charCodeAt ( ) ] ++ ; let fact = 1 ; for ( let i = 0 ; i < MAX_CHAR ; i ++ ) fact = fact * factorial ( freq [ i ] ) ; return parseInt ( factorial ( length ) / fact , 10 ) ; } let str = " " ; document . write ( countDistinctPermutations ( str ) ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function uniqueCharacters ( str ) { let checker = 0 ; for ( let i = 0 ; i < str . length ; i ++ ) { let bitAtIndex = str [ i ] - ' ' ; if ( ( checker & ( 1 << bitAtIndex ) ) > 0 ) { return false ; } checker = checker | ( 1 << bitAtIndex ) ; } return true ; } let input = " " ; if ( uniqueCharacters ( input ) ) { document . write ( " " + input + " " ) ; } else { document . write ( " " + input + " " ) ; }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
var MAX_CHAR = 26 ; function countSubstringWithEqualEnds ( s ) { var result = 0 ; var n = s . length ; var count = Array . from ( { length : MAX_CHAR } , ( _ , i ) => 0 ) ; for ( var i = 0 ; i < n ; i ++ ) count [ s . charAt ( i ) . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] ++ ; for ( var i = 0 ; i < MAX_CHAR ; i ++ ) result += ( count [ i ] * ( count [ i ] + 1 ) / 2 ) ; return result ; } var s = " " ; document . write ( countSubstringWithEqualEnds ( s ) ) ;

Index/key variables: i
Accumulator variables: i, result
Iterator variables: i
Javascript program:
function maxRepeating ( str ) { var n = str . length ; var count = 0 ; var res = str [ 0 ] ; var cur_count = 1 ; for ( var i = 0 ; i < n ; i ++ ) { if ( i < n - 1 && str [ i ] == str [ i + 1 ] ) cur_count ++ ; else { if ( cur_count > count ) { count = cur_count ; res = str [ i ] ; } cur_count = 1 ; } } return res ; } var str = " " ; document . write ( maxRepeating ( str ) ) ;

Index/key variables: i
Accumulator variables: cur_count, i
Iterator variables: i
Javascript program:
let MAX = 10000 ; let CHAR_SIZE = 26 ; function precompute ( mat , str , len ) { for ( let i = 0 ; i < CHAR_SIZE ; ++ i ) mat [ len ] [ i ] = len ; for ( let i = len - 1 ; i >= 0 ; -- i ) { for ( let j = 0 ; j < CHAR_SIZE ; ++ j ) mat [ i ] [ j ] = mat [ i + 1 ] [ j ] ; mat [ i ] [ str [ i ] . charCodeAt ( ) - ' ' . charCodeAt ( ) ] = i ; } } function query ( mat , str , len ) { let pos = 0 ; for ( let i = 0 ; i < str . length ; ++ i ) { if ( mat [ pos ] [ str [ i ] . charCodeAt ( ) - ' ' . charCodeAt ( ) ] >= len ) return false ; else pos = mat [ pos ] [ str [ i ] . charCodeAt ( ) - ' ' . charCodeAt ( ) ] + 1 ; } return true ; } let S = " " ; let len = S . length ; let mat = new Array ( MAX ) ; for ( let i = 0 ; i < MAX ; i ++ ) { mat [ i ] = new Array ( CHAR_SIZE ) ; for ( let j = 0 ; j < CHAR_SIZE ; j ++ ) { mat [ i ] [ j ] = 0 ; } } precompute ( mat , S , len ) ; let get = query ( mat , " " , len ) ? " " : " " ; document . write ( get + " " ) ; get = query ( mat , " " , len ) ? " " : " " ; document . write ( get + " " ) ; get = query ( mat , " " , len ) ? " " : " " ; document . write ( get + " " ) ; get = query ( mat , " " , len ) ? " " : " " ; document . write ( get + " " ) ;

Index/key variables: i, j, len, pos
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
function query ( s , i , j ) { let n = s . length ; i %= n ; j %= n ; if ( s [ i ] == s [ j ] ) document . write ( " " + " " ) ; else document . write ( " " + " " ) ; } let X = " " ; query ( X , 0 , 8 ) ; query ( X , 8 , 13 ) ; query ( X , 6 , 15 ) ;

Index/key variables: i, j
Javascript program:
function countPairs ( str ) { let result = 0 ; let n = str . length ; for ( let i = 0 ; i < n ; i ++ ) for ( let j = i + 1 ; j < n ; j ++ ) if ( Math . abs ( str [ i ] . charCodeAt ( ) - str [ j ] . charCodeAt ( ) ) == Math . abs ( i - j ) ) result ++ ; return result ; } let str = " " ; document . write ( countPairs ( str ) ) ;

Index/key variables: i, j
Accumulator variables: i, j, result
Iterator variables: i, j
Javascript program:
function min ( a , b ) { if ( a < b ) return a ; else return b ; } function longestString ( str1 , str2 ) { var count1 = new Array ( 26 ) ; var count2 = new Array ( 26 ) ; count1 . fill ( 0 ) ; count2 . fill ( 0 ) ; for ( var i = 0 ; i < str1 . length ; i ++ ) { count1 [ str1 . charCodeAt ( i ) - 97 ] ++ ; } for ( var i = 0 ; i < str2 . length ; i ++ ) { count2 [ str2 . charCodeAt ( i ) - 97 ] ++ ; } var result = " " ; for ( var i = 0 ; i < 26 ; i ++ ) { for ( var j = 1 ; j <= min ( count1 [ i ] , count2 [ i ] ) ; j ++ ) { result += String . fromCharCode ( 97 + i ) ; } } document . write ( result ) ; } var str1 = " " ; var str2 = " " ; longestString ( str1 , str2 ) ;

Index/key variables: i
Accumulator variables: i, j, result
Iterator variables: i, j
Javascript program:
function checkPattern ( str , pattern ) { var len = pattern . length ; if ( str . length < len ) { return false ; } for ( var i = 0 ; i < len - 1 ; i ++ ) { var x = pattern [ i ] ; var y = pattern [ i + 1 ] ; var last = str . lastIndexOf ( x ) ; var first = str . indexOf ( y ) ; if ( last === - 1 first === - 1 last > first ) { return false ; } } return true ; } var str = " " ; var pattern = " " ; document . write ( checkPattern ( str , pattern ) ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function findSum ( str ) { let temp = " " ; let sum = 0 ; for ( let i = 0 ; i < str . length ; i ++ ) { let ch = str [ i ] ; if ( ! isNaN ( String ( ch ) * 1 ) ) temp += ch ; else { sum += parseInt ( temp ) ; temp = " " ; } } return sum + parseInt ( temp ) ; } let str = " " ; document . write ( findSum ( str ) ) ;

Index/key variables: i
Accumulator variables: i, sum, temp
Iterator variables: i