dhyuti-n/xlcost-variable-roles huggingface dataset:
Javascript program:
var CHARS = " " ; var DIGITS = 16 ; function isDivisible ( s , m ) { var mp = new Map ( ) ; for ( var i = 0 ; i < DIGITS ; i ++ ) { mp . set ( CHARS [ i ] , i ) ; } var r = 0 ; for ( var i = 0 ; i < s . length ; i ++ ) { r = ( r * 16 + mp . get ( s [ i ] ) ) % m ; } if ( ! r ) return true ; return false ; } var s = " " ; var m = 3 ; if ( isDivisible ( s , m ) ) document . write ( " " ) ; else document . write ( " " ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function cntSplits ( s ) { if ( s [ s . length - 1 ] == ' ' ) return - 1 ; var ans = 0 ; for ( var i = 0 ; i < s . length ; i ++ ) ans += ( s [ i ] == ' ' ) ; return ans ; } var s = " " ; document . write ( cntSplits ( s ) ) ;

Index/key variables: i
Accumulator variables: ans, i
Iterator variables: i
Javascript program:
var CHARS = " " ; var MAX = 26 ; function getString ( string , n ) { var string = string . split ( " " ) ; uMap = [ ] ; for ( let i = 0 ; i < MAX ; i ++ ) { uMap [ CHARS [ i ] ] = CHARS [ ( i + 1 ) % MAX ] ; } for ( let i = 0 ; i < n ; i ++ ) { string [ i ] = uMap [ string [ i ] ] ; } return string . join ( " " ) ; } var string = " " ; var n = string . length ; document . write ( getString ( string , n ) ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function Count ( s , pos ) { let c = s [ pos - 1 ] ; let counter = 0 ; for ( let i = 0 ; i < pos - 1 ; i ++ ) { if ( s [ i ] == c ) counter = counter + 1 ; } return counter ; } let s = " " ; let pos ; let n = s . length ; let query = [ 9 , 3 , 2 ] ; let Q = query . length ; for ( let i = 0 ; i < Q ; i ++ ) { pos = query [ i ] ; document . write ( Count ( s , pos ) + " " ) ; }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
var sticks = [ 6 , 2 , 5 , 5 , 4 , 5 , 6 , 3 , 7 , 6 ] function countSticks ( str , n ) { var cnt = 0 ; for ( var i = 0 ; i < n ; i ++ ) { cnt += ( sticks [ str [ i ] - ' ' ] ) ; } return cnt ; } var str = " " ; var n = str . length ; document . write ( countSticks ( str , n ) ) ;

Index/key variables: i
Accumulator variables: cnt, i
Iterator variables: i
Javascript program:
function printChar ( arr , len ) { let occ = new Map ( ) ; for ( let i = 0 ; i < len ; i ++ ) if ( occ . has ( arr [ i ] ) ) { occ . set ( arr [ i ] , occ . get ( arr [ i ] ) + 1 ) ; } else { occ . set ( arr [ i ] , 1 ) ; } let size = occ . size ; while ( size -- > 0 ) { let currentMax = 0 ; let arg_max = 0 ; for ( let [ key , value ] of occ . entries ( ) ) { if ( value > currentMax || ( value == currentMax && key > arg_max ) ) { arg_max = key ; currentMax = value ; } } document . write ( arg_max + " " + currentMax + " " ) ; occ . delete ( arg_max ) ; } } let str = " " ; let len = str . length ; printChar ( str . split ( " " ) , len ) ;

Index/key variables: i
Accumulator variables: i, size
Iterator variables: i
Javascript program:
function getMod ( str , n , k ) { var pwrTwo = Array ( n ) ; pwrTwo [ 0 ] = 1 % k ; for ( var i = 1 ; i < n ; i ++ ) { pwrTwo [ i ] = pwrTwo [ i - 1 ] * ( 2 % k ) ; pwrTwo [ i ] %= k ; } var res = 0 ; var i = 0 , j = n - 1 ; while ( i < n ) { if ( str [ j ] == ' ' ) { res += ( pwrTwo [ i ] ) ; res %= k ; } i ++ ; j -- ; } return res ; } var str = " " ; var n = str . length ; var k = 45 ; document . write ( getMod ( str , n , k ) ) ;

Index/key variables: i, j
Accumulator variables: i, j, res
Iterator variables: i
Javascript program:
var MOD = 1000000007 ; function countStrings ( N ) { var i , j ; var dp = Array ( N + 1 ) . fill ( 0 ) . map ( x => Array ( 3 ) . fill ( 0 ) ) ; for ( i = 0 ; i < N + 1 ; i ++ ) { for ( j = 9 ; j < 3 ; j ++ ) { dp [ i ] [ j ] = 0 ; } } dp [ 1 ] [ 0 ] = 1 ; dp [ 1 ] [ 1 ] = 1 ; dp [ 1 ] [ 2 ] = 0 ; for ( i = 2 ; i <= N ; i ++ ) { dp [ i ] [ 0 ] = ( dp [ i - 1 ] [ 0 ] + dp [ i - 1 ] [ 1 ] + dp [ i - 1 ] [ 2 ] ) % MOD ; dp [ i ] [ 1 ] = dp [ i - 1 ] [ 0 ] % MOD ; dp [ i ] [ 2 ] = dp [ i - 1 ] [ 1 ] % MOD ; } var ans = ( dp [ N ] [ 0 ] + dp [ N ] [ 1 ] + dp [ N ] [ 2 ] ) % MOD ; return ans ; } var N = 3 ; document . write ( countStrings ( N ) ) ;

Index/key variables: N, i, j
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
function maxNumber ( str , n ) { var freq = Array ( 2 ) . fill ( 0 ) ; for ( var i = 0 ; i < n ; i ++ ) { if ( str [ i ] == ' ' ) { freq [ 0 ] ++ ; } else if ( str [ i ] == ' ' ) { freq [ 1 ] ++ ; } } var num = " " ; for ( var i = 0 ; i < freq [ 1 ] ; i ++ ) num += ' ' ; for ( var i = 0 ; i < freq [ 0 ] ; i ++ ) num += ' ' ; return num ; } var str = " " ; var n = str . length ; document . write ( maxNumber ( str , n ) ) ;

Index/key variables: i
Accumulator variables: i, num
Iterator variables: i
Javascript program:
function decToBinary ( n ) { var binaryNum = Array ( 32 ) ; var i = 0 ; while ( n > 0 ) { binaryNum [ i ] = n % 2 ; n = parseInt ( n / 2 ) ; i ++ ; } var binary = " " ; for ( var j = i - 1 ; j >= 0 ; j -- ) binary += ( binaryNum [ j ] . toString ( ) ) ; return binary ; } function countFreq ( pat , txt ) { var M = pat . length ; var N = txt . length ; var res = 0 ; for ( var i = 0 ; i <= N - M ; i ++ ) { var j ; for ( j = 0 ; j < M ; j ++ ) if ( txt [ i + j ] != pat [ j ] ) break ; if ( j == M ) { res ++ ; j = 0 ; } } return res ; } function findOccurrence ( arr , n , pattern ) { for ( var i = 0 ; i < n ; i ++ ) { var binary = decToBinary ( arr [ i ] ) ; document . write ( countFreq ( pattern , binary ) + " " ) ; } } var arr = [ 5 , 106 , 7 , 8 ] ; var pattern = " " ; var n = arr . length ; findOccurrence ( arr , n , pattern ) ;

Index/key variables: i, j
Accumulator variables: binary, i, j, res
Iterator variables: i, j
Javascript program:
function canBeBalanced ( s , n ) { if ( n % 2 == 1 ) return false ; let k = " " ; k += s + " " ; let d = [ ] ; for ( let i = 0 ; i < k . length ; i ++ ) { if ( k [ i ] == ' ' ) d . push ( " " ) ; else { if ( d . length != 0 ) d . pop ( ) ; else return false ; } } if ( d . length == 0 ) return true ; return false ; } let s = " " ; let n = s . length ; if ( canBeBalanced ( s , n ) ) document . write ( " " ) ; else document . write ( " " ) ;

Index/key variables: i
Accumulator variables: i, k
Iterator variables: i
Javascript program:
function find_winner ( str , n ) { var str1 = " " , str2 = " " ; for ( var i = 0 ; i < n ; i ++ ) { if ( i % 2 == 0 ) { str1 += str [ i ] ; } else { str2 += str [ i ] ; } } str1 = str1 . split ( ' ' ) . sort ( ) ; str2 = str2 . split ( ' ' ) . sort ( ) ; if ( str1 < str2 ) document . write ( " " ) ; else if ( str2 < str1 ) document . write ( " " ) ; else document . write ( " " ) ; } var str = " " ; var n = str . length ; find_winner ( str , n ) ;

Index/key variables: i
Accumulator variables: i, str1, str2
Iterator variables: i
Javascript program:
function expandString ( strin ) { let temp = " " ; let j ; for ( let i = 0 ; i < strin . length ; i ++ ) { if ( strin [ i ] . charCodeAt ( 0 ) >= 0 ) { let num = strin [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ; if ( strin [ i + 1 ] == ' ' ) { for ( j = i + 1 ; strin [ j ] != ' ' ; j ++ ) { if ( ( strin [ j ] >= ' ' && strin [ j ] <= ' ' ) || ( strin [ j ] >= ' ' && strin [ j ] <= ' ' ) ) { temp += strin [ j ] ; } } for ( let k = 1 ; k <= num ; k ++ ) { document . write ( temp ) ; } num = 0 ; temp = " " ; if ( j < strin . length ) { i = j ; } } } } } let strin = " " ; expandString ( strin ) ;

Index/key variables: i, j
Accumulator variables: i, j, k, temp
Iterator variables: i, j, k
Javascript program:
function longest_substring ( s , k ) { var n = s . length ; if ( k > 1 ) { s += s ; n *= 2 ; } var ans = 0 ; var i = 0 ; while ( i < n ) { var x = 0 ; while ( s [ i ] == ' ' && i < n ) x ++ , i ++ ; ans = Math . max ( ans , x ) ; i ++ ; } if ( k == 1 ans != n ) return ans ; else return ( ans / 2 ) * k ; } var s = " " ; var k = 4 ; document . write ( longest_substring ( s , k ) ) ;

Index/key variables: i
Accumulator variables: i, n, s, x
Javascript program:
function Occurrence ( s , position ) { let count = 0 ; for ( let i = 0 ; i < position - 1 ; i ++ ) if ( s [ i ] == s [ position - 1 ] ) count ++ ; return count ; } let s = " " ; let p = 9 ; document . write ( Occurrence ( s , p ) ) ;

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Javascript program:
function countOccurrence ( s , position ) { let alpha = new Array ( 26 ) ; for ( let i = 0 ; i < 26 ; i ++ ) { alpha [ i ] = 0 ; } let b = new Array ( s . length ) ; for ( let i = 0 ; i < s . length ; i ++ ) { b [ i ] = alpha [ s [ i ] . charCodeAt ( 0 ) - 97 ] ; alpha [ s [ i ] . charCodeAt ( 0 ) - 97 ] ++ ; } return b [ position - 1 ] ; } let s = " " ; p = 9 ; document . write ( countOccurrence ( s , p ) ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
var MAX = 26 ; function canBeMapped ( s1 , l1 , s2 , l2 ) { if ( l1 != l2 ) return false ; var freq1 = Array ( MAX ) . fill ( 0 ) ; var freq2 = Array ( MAX ) . fill ( 0 ) ; for ( var i = 0 ; i < l1 ; i ++ ) freq1 [ s1 [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] ++ ; for ( var i = 0 ; i < l2 ; i ++ ) freq2 [ s2 [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] ++ ; for ( var i = 0 ; i < MAX ; i ++ ) { if ( freq1 [ i ] == 0 ) continue ; var found = false ; for ( var j = 0 ; j < MAX ; j ++ ) { if ( freq1 [ i ] == freq2 [ j ] ) { freq2 [ j ] = - 1 ; found = true ; break ; } } if ( ! found ) return false ; } return true ; } var s1 = " " ; var s2 = " " ; var l1 = s1 . length ; var l2 = s2 . length ; if ( canBeMapped ( s1 , l1 , s2 , l2 ) ) document . write ( " " ) ; else document . write ( " " ) ;

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Boolean variables: found
Javascript program:
let stringSet = new Set ( ) ; function find_permutation ( str1 , str2 , len1 , len2 , i , j , res ) { if ( res . length == len1 + len2 ) { stringSet . add ( res ) ; return ; } if ( i < len1 ) find_permutation ( str1 , str2 , len1 , len2 , i + 1 , j , res + str1 [ i ] ) ; if ( j < len2 ) find_permutation ( str1 , str2 , len1 , len2 , i , j + 1 , res + str2 [ j ] ) ; } function print_set ( ) { for ( let s of stringSet . values ( ) ) { document . write ( s + " " ) ; } } let str1 = " " , str2 = " " ; let len1 = str1 . length ; let len2 = str2 . length ; find_permutation ( str1 , str2 , len1 , len2 , 0 , 0 , " " ) ; print_set ( ) ;

Index/key variables: i, j
Iterator variables: s
Javascript program:
function countSubStr ( s , n ) { var count = 0 ; for ( i = 0 ; i < n - 2 ; ) { if ( s [ i ] == ' ' && s [ i + 1 ] == ' ' && s [ i + 2 ] == ' ' ) { count ++ ; i += 3 ; } else if ( s [ i ] == ' ' && s [ i + 1 ] == ' ' && s [ i + 2 ] == ' ' ) { count ++ ; i += 3 ; } else { i ++ ; } } return count ; } var s = " " ; var n = s . length ; document . write ( countSubStr ( s , n ) ) ;

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Javascript program:
function countTotalDistinct ( str ) { let cnt = 0 ; let items = new Set ( ) ; for ( let i = 0 ; i < str . length ; ++ i ) { let temp = " " ; let ans = new Set ( ) ; for ( let j = i ; j < str . length ; ++ j ) { temp = temp + str [ j ] ; ans . add ( str [ j ] ) ; if ( ! items . has ( temp ) ) { items . add ( temp ) ; cnt += ans . size ; } } } return cnt ; } let str = " " ; document . write ( countTotalDistinct ( str ) ) ;

Index/key variables: j
Accumulator variables: cnt
Iterator variables: i, j
Javascript program:
function division_of_string ( str , k ) { let n = str . length ; let has = new Map ( ) ; let ans = 0 , cnt = 0 , i = 0 ; while ( i < n ) { if ( ! has . has ( str [ i ] ) ) { cnt ++ ; has . set ( str [ i ] , true ) ; } if ( cnt == k ) { ans = i ; break ; } i ++ ; } i ++ ; has . clear ( ) ; cnt = 0 ; while ( i < n ) { if ( ! has . has ( str [ i ] ) ) { cnt ++ ; has . set ( str [ i ] , true ) ; } if ( cnt == k ) { break ; } i ++ ; } if ( cnt < k ) { document . write ( " " + " " ) ; } else { i = 0 ; while ( i <= ans ) { document . write ( str [ i ] ) ; i ++ ; } document . write ( " " + " " ) ; while ( i < n ) { document . write ( str [ i ] ) ; i ++ ; } document . write ( " " + " " ) ; } document . write ( " " + " " ) ; } let str = " " ; let k = 4 ; division_of_string ( str . split ( ' ' ) , k ) ;

Index/key variables: i
Accumulator variables: cnt, i
Javascript program:
function removeDuplicates ( S ) { var ans = " " ; for ( i = 0 ; i < S . length ; i ++ ) { if ( ans . length == 0 || ans . charAt ( ans . length - 1 ) != S . charAt ( i ) ) ans += S . charAt ( i ) ; else if ( ans . charAt ( ans . length - 1 ) == S . charAt ( i ) ) ans = ans . substring ( 0 , ans . length - 1 ) ; } return ans ; } var str = " " ; document . write ( removeDuplicates ( str ) ) ;

Accumulator variables: ans, i
Iterator variables: i
Javascript program:
function swap ( str , i , j ) { let sb = str . split ( " " ) ; sb [ i ] = str [ j ] ; sb [ j ] = str [ i ] ; return sb . join ( " " ) ; } function reverseWords ( str ) { let start = 0 ; for ( let i = 0 ; i < str . length ; i ++ ) { if ( str [ i ] == ' ' i == str . length - 1 ) { let end ; if ( i == str . length - 1 ) end = i ; else end = i - 1 ; while ( start < end ) { str = swap ( str , start , end ) ; start ++ ; end -- ; } start = i + 1 ; } } return str ; } let str = " " ; document . write ( reverseWords ( str ) ) ;

Index/key variables: i, j
Accumulator variables: end, i, start
Iterator variables: i
Javascript program:
function reverse ( k ) { let s = [ ] ; let token = k . split ( " " ) ; for ( let i = 0 ; i < token . length ; i ++ ) { s . push ( token [ i ] ) ; } while ( s . length > 0 ) { document . write ( s [ s . length - 1 ] + " " ) ; s . pop ( ) ; } } let k = " " ; reverse ( k ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function countSubString ( s , c , k ) { var leftCount = 0 , rightCount = 0 ; var left = 0 , right = 0 ; var freq = 0 ; var result = 0 , len = s . length ; while ( s [ left ] !== c && left < len ) { left ++ ; leftCount ++ ; } right = left + 1 ; while ( freq !== k - 1 && right - 1 < len ) { if ( s [ right ] === c ) freq ++ ; right ++ ; } while ( left < len && right - 1 < len ) { while ( s [ left ] !== c && left < len ) { left ++ ; leftCount ++ ; } while ( right < len && s [ right ] !== c ) { if ( s [ right ] === c ) freq ++ ; right ++ ; rightCount ++ ; } result = result + ( leftCount + 1 ) * ( rightCount + 1 ) ; freq = k - 1 ; leftCount = 0 ; rightCount = 0 ; left ++ ; right ++ ; } return result ; } var s = " " ; var c = " " ; var k = 2 ; document . write ( countSubString ( s , c , k ) ) ;

Index/key variables: left, right
Accumulator variables: freq, left, leftCount, right, rightCount
Javascript program:
function solve ( test , MOD ) { let size = test . length ; let total = 0 ; for ( let i = 0 ; i <= 8 ; i ++ ) { let x = i ; let y = i + 1 ; let newtest = " " ; for ( let j = 0 ; j < size ; j ++ ) { if ( test [ j ] . charCodeAt ( 0 ) == x + 48 || test [ j ] . charCodeAt ( 0 ) == y + 48 ) { newtest += test [ j ] ; } } if ( newtest . length > 0 ) { let size1 = newtest . length ; let prefix = new Array ( size1 ) ; for ( let j = 0 ; j < size1 ; j ++ ) { prefix [ j ] = 0 ; if ( newtest [ j ] . charCodeAt ( 0 ) == y + 48 ) { prefix [ j ] ++ ; } } for ( let j = 1 ; j < size1 ; j ++ ) { prefix [ j ] += prefix [ j - 1 ] ; } let count = 0 ; let firstcount = 0 ; let ss = 0 ; let prev = 0 ; for ( let j = 0 ; j < size1 ; j ++ ) { if ( newtest [ j ] . charCodeAt ( 0 ) == x + 48 ) { count ++ ; firstcount ++ ; } else { ss += count * count ; let pairsum = Math . floor ( ( firstcount * firstcount - ss ) / 2 ) ; let temp = pairsum ; pairsum -= prev ; prev = temp ; let secondway = prefix [ size1 - 1 ] ; if ( j != 0 ) secondway -= prefix [ j - 1 ] ; let answer = count * ( count - 1 ) * secondway * ( secondway - 1 ) ; answer = Math . floor ( answer / 4 ) ; answer += Math . floor ( ( pairsum * secondway * ( secondway - 1 ) ) / 2 ) ; total += answer ; count = 0 ; } } } } return total ; } let test = " " ; let MOD = 1000000007 ; document . write ( solve ( test , MOD ) ) ;

Index/key variables: j
Accumulator variables: answer, count, firstcount, i, j, newtest, pairsum, secondway, ss, total
Iterator variables: i, j
Javascript program:
const MAX = 26 ; function countPairs ( str , k ) { var n = str . length ; var freq = new Array ( MAX ) . fill ( 0 ) ; for ( var i = 0 ; i < n ; i ++ ) { freq [ str [ i ] . charCodeAt ( 0 ) - " " . charCodeAt ( 0 ) ] ++ ; } var cnt = 0 ; if ( k === 0 ) { for ( var i = 0 ; i < MAX ; i ++ ) { if ( freq [ i ] > 1 ) { cnt += ( freq [ i ] * ( freq [ i ] - 1 ) ) / 2 ; } } } else { for ( var i = 0 ; i < MAX ; i ++ ) { if ( freq [ i ] > 0 && i + k < MAX && freq [ i + k ] > 0 ) { cnt += freq [ i ] * freq [ i + k ] ; } } } return cnt ; } var str = " " ; var k = 0 ; document . write ( countPairs ( str . split ( " " ) , k ) ) ;

Index/key variables: i
Accumulator variables: cnt, i
Iterator variables: i
Javascript program:
function isPalin ( i , j , k , l , p , q , s ) { var start = i , end = q ; while ( start < end ) { if ( s [ start ] != s [ end ] ) return false ; start ++ ; if ( start == j + 1 ) start = k ; end -- ; if ( end == p - 1 ) end = l ; } return true ; } function countSubStr ( s ) { var count = 0 ; var n = s . length ; for ( var i = 0 ; i < n - 2 ; i ++ ) { for ( var j = i ; j < n - 2 ; j ++ ) { for ( var k = j + 1 ; k < n - 1 ; k ++ ) { for ( var l = k ; l < n - 1 ; l ++ ) { for ( var p = l + 1 ; p < n ; p ++ ) { for ( var q = p ; q < n ; q ++ ) { if ( isPalin ( i , j , k , l , p , q , s ) ) { count ++ ; } } } } } } } return count ; } var s = " " ; document . write ( countSubStr ( s ) ) ;

Index/key variables: end, start
Accumulator variables: count, end, i, j, k, l, p, q, start
Iterator variables: i, j, k, l, p, q
Javascript program:
function isPrime ( n ) { if ( n == 0 n == 1 ) return false ; for ( let i = 2 ; i * i <= n ; i ++ ) if ( n % i == 0 ) return false ; return true ; } function sumAscii ( str , n ) { let sum = 0 ; for ( let i = 0 ; i < n ; i ++ ) { if ( isPrime ( i + 1 ) ) sum += str . charCodeAt ( i ) ; } return sum ; } let str = " " ; let n = str . length ; document . write ( sumAscii ( str , n ) ) ;

Accumulator variables: i, sum
Iterator variables: i
Javascript program:
let graph = new Array ( ) ; for ( let i = 0 ; i < 100 ; i ++ ) { graph . push ( [ ] ) } let weight = new Array ( 100 ) . fill ( 0 ) ; function Pangram ( x ) { let mp = new Map ( ) ; let n = x . length ; for ( let i = 0 ; i < n ; i ++ ) { if ( mp . has ( x [ i ] ) ) { mp . set ( x [ i ] , mp . get ( x [ i ] ) + 1 ) } else { mp . set ( x [ i ] , 1 ) } } if ( mp . size == 26 ) return true ; else return false ; } function countTotalPangram ( n ) { let cnt = 0 ; for ( let i = 1 ; i <= n ; i ++ ) if ( Pangram ( weight [ i ] ) ) cnt ++ ; return cnt ; } function dfs ( node , parent ) { for ( let to of graph [ node ] ) { if ( to == parent ) continue ; dfs ( to , node ) ; weight [ node ] += weight [ to ] ; } } let n = 6 ; weight [ 1 ] = " " ; weight [ 2 ] = " " ; weight [ 3 ] = " " ; weight [ 4 ] = " " ; weight [ 5 ] = " " ; weight [ 6 ] = " " ; graph [ 1 ] . push ( 2 ) ; graph [ 2 ] . push ( 3 ) ; graph [ 2 ] . push ( 4 ) ; graph [ 1 ] . push ( 5 ) ; graph [ 5 ] . push ( 6 ) ; dfs ( 1 , 1 ) ; document . write ( countTotalPangram ( n ) ) ;

Index/key variables: i, node, to
Accumulator variables: cnt, i
Iterator variables: i, to
Javascript program:
let cnt = 0 ; let graph = new Array ( ) ; for ( let i = 0 ; i < 100 ; i ++ ) { graph . push ( [ ] ) } let weight = new Array ( 100 ) ; function uniqueChars ( x ) { let mp = new Map ( ) ; let n = x . length ; for ( let i = 0 ; i < n ; i ++ ) { if ( mp . has ( x [ i ] ) ) { mp . set ( x [ i ] , mp . get ( x [ i ] ) + 1 ) } else { mp . set ( x [ i ] , 1 ) } } if ( mp . size == x . length ) return true ; else return false ; } function dfs ( node , parent ) { if ( uniqueChars ( weight [ node ] ) ) cnt += 1 ; for ( let to of graph [ node ] ) { if ( to == parent ) continue ; dfs ( to , node ) ; } } weight [ 1 ] = " " ; weight [ 2 ] = " " ; weight [ 3 ] = " " ; weight [ 4 ] = " " ; weight [ 5 ] = " " ; graph [ 1 ] . push ( 2 ) ; graph [ 2 ] . push ( 3 ) ; graph [ 2 ] . push ( 4 ) ; graph [ 1 ] . push ( 5 ) ; dfs ( 1 , 1 ) ; document . write ( cnt ) ;

Index/key variables: i, node
Accumulator variables: cnt, i
Iterator variables: i, to
Javascript program:
let MAX = 256 ; function lastNonRepeating ( str , n ) { let freq = new Array ( MAX ) ; for ( let i = 0 ; i < MAX ; i ++ ) { freq [ i ] = 0 ; } for ( let i = 0 ; i < n ; i ++ ) freq [ str [ i ] . charCodeAt ( 0 ) ] ++ ; for ( let i = n - 1 ; i >= 0 ; i -- ) { let ch = str [ i ] ; if ( freq [ ch . charCodeAt ( 0 ) ] == 1 ) return ( " " + ch ) ; } return " " ; } let str = " " ; let n = str . length ; document . write ( lastNonRepeating ( str , n ) ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function findCount ( s , n , a , b ) { var res = 0 ; for ( var i = 0 ; i < b ; i ++ ) { if ( i == a ) res += ( s [ n - i - 1 ] != ' ' ) ; else res += ( s [ n - i - 1 ] != ' ' ) ; } return res ; } var str = " " ; var N = str . length ; var A = 3 , B = 6 ; document . write ( findCount ( str , N , A , B ) ) ;

Accumulator variables: i, res
Iterator variables: i
Javascript program:
const NUM = 31 ; function positions ( str , n ) { for ( i = 0 ; i < n ; i ++ ) { document . write ( ( str [ i ] . charCodeAt ( 0 ) & NUM ) + " " ) ; } } var str = " " ; var n = str . length ; positions ( str , n ) ;

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

Index/key variables: i
Accumulator variables: i, len
Iterator variables: i
Javascript program:
function makePalindrome ( str ) { var i = 0 , j = str . length - 1 ; while ( i <= j ) { if ( str [ i ] == ' ' && str [ j ] == ' ' ) { str [ i ] = ' ' ; str [ j ] = ' ' ; } else if ( str [ j ] == ' ' ) str [ j ] = str [ i ] ; else if ( str [ i ] == ' ' ) str [ i ] = str [ j ] ; else if ( str [ i ] != str [ j ] ) return " " ; i ++ ; j -- ; } return str . join ( " " ) ; } var str = " " . split ( ' ' ) ; document . write ( makePalindrome ( str ) ) ;

Index/key variables: i, j
Accumulator variables: i, j
Javascript program:
function calcScore ( str ) { var score = 0 ; var len = str . length ; for ( var i = 0 ; i < len ; ) { var chunkSize = 1 ; var currentChar = str [ i ++ ] ; while ( i < len && str [ i ] == currentChar ) { chunkSize ++ ; i ++ ; } if ( currentChar == ' ' ) score += Math . pow ( chunkSize , 2 ) ; else score -= Math . pow ( chunkSize , 2 ) ; } return score ; } var str = " " ; document . write ( calcScore ( str ) ) ;

Index/key variables: i
Accumulator variables: chunkSize, i, score
Iterator variables: i
Javascript program:
function countSubString ( s , c , k ) { var leftCount = 0 , rightCount = 0 ; var left = 0 , right = 0 ; var freq = 0 ; var result = 0 , len = s . length ; while ( s [ left ] != c && left < len ) { left ++ ; leftCount ++ ; } right = left + 1 ; while ( freq != ( k - 1 ) && ( right - 1 ) < len ) { if ( s [ right ] == c ) freq ++ ; right ++ ; } while ( left < len && ( right - 1 ) < len ) { while ( s [ left ] != c && left < len ) { left ++ ; leftCount ++ ; } while ( right < len && s [ right ] != c ) { if ( s [ right ] == c ) freq ++ ; right ++ ; rightCount ++ ; } result = result + ( leftCount + 1 ) * ( rightCount + 1 ) ; freq = k - 1 ; leftCount = 0 ; rightCount = 0 ; left ++ ; right ++ ; } return result ; } var s = " " ; var c = ' ' ; var k = 2 ; document . write ( countSubString ( s , c , k ) + " " ) ;

Index/key variables: left, right
Accumulator variables: freq, left, leftCount, right, rightCount