dhyuti-n/xlcost-variable-roles huggingface dataset:
Javascript program:
let d = 256 ; function search ( pat , txt , q ) { let M = pat . length ; let N = txt . length ; let i , j ; let p = 0 ; let t = 0 ; let h = 1 ; for ( i = 0 ; i < M - 1 ; i ++ ) h = ( h * d ) % q ; for ( i = 0 ; i < M ; i ++ ) { p = ( d * p + pat [ i ] . charCodeAt ( ) ) % q ; t = ( d * t + txt [ i ] . charCodeAt ( ) ) % q ; } for ( i = 0 ; i <= N - M ; i ++ ) { if ( p == t ) { for ( j = 0 ; j < M ; j ++ ) { if ( txt [ i + j ] != pat [ j ] ) break ; } if ( j == M ) document . write ( " " + i + " " ) ; } if ( i < N - M ) { t = ( d * ( t - txt [ i ] . charCodeAt ( ) * h ) + txt [ i + M ] . charCodeAt ( ) ) % q ; if ( t < 0 ) t = ( t + q ) ; } } } let txt = " " ; let pat = " " ; let q = 101 ; search ( pat , txt , q ) ;

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
const MAXN = 100001 ; let spf = new Array ( MAXN ) . fill ( 0 ) ; const sieve = ( ) => { spf [ 1 ] = 1 ; for ( let i = 2 ; i < MAXN ; i ++ ) spf [ i ] = i ; for ( let i = 4 ; i < MAXN ; i += 2 ) spf [ i ] = 2 ; for ( let i = 3 ; i * i < MAXN ; i ++ ) { if ( spf [ i ] == i ) { for ( let j = i * i ; j < MAXN ; j += i ) { if ( spf [ j ] == j ) spf [ j ] = i ; } } } } const getFactorization = ( x ) => { let ret = [ ] ; while ( x != 1 ) { ret . push ( spf [ x ] ) ; let value = spf [ x ] ; while ( x % value == 0 ) x = parseInt ( x / value ) ; } return ret ; } const flipString = ( S , arr , M ) => { sieve ( ) ; let frequency = new Array ( MAXN ) . fill ( 0 ) ; for ( let i = 0 ; i < M ; i ++ ) { let primeFactors = getFactorization ( arr [ i ] ) ; for ( let factors in primeFactors ) { frequency [ primeFactors [ factors ] ] ++ ; frequency [ factors ] %= 2 ; } } let N = S . length ; for ( let i = 0 ; i < MAXN ; i ++ ) { if ( frequency [ i ] & 1 ) { for ( let j = i ; j <= N ; j += i ) { S [ j - 1 ] = ( S [ j - 1 ] == ' ' ? ' ' : ' ' ) ; } } } return S ; } let S = " " ; S = S . split ( " " ) ; let arr = [ 2 , 4 , 6 ] ; let M = arr . length ; document . write ( flipString ( S , arr , M ) . join ( ' ' ) ) ;

Index/key variables: factors, i, j, x
Accumulator variables: i, j
Iterator variables: factors, i, j
Javascript program:
function isOnesGreater ( S , N ) { let cnt0 = 0 ; let cnt1 = 0 ; for ( let i = 0 ; i < N ; i ++ ) { if ( S [ i ] == ' ' ) cnt1 ++ ; else cnt0 ++ ; } for ( let i = 0 ; i < N ; i ++ ) { if ( S [ i ] == ' ' ) { if ( i > 0 && S [ i - 1 ] == ' ' ) { S [ i - 1 ] = ' ' ; cnt0 -- ; } else if ( i < N && S [ i + 1 ] == ' ' ) { S [ i + 1 ] = ' ' ; cnt0 -- ; } } } if ( cnt1 > cnt0 ) { document . write ( " " ) ; } else { document . write ( " " ) ; } } let S = " " ; let N = S . length ; isOnesGreater ( S , N ) ;

Index/key variables: i
Accumulator variables: cnt0, cnt1, i
Iterator variables: i
Javascript program:
function minOperation ( St , K , N ) { S = St . split ( ' ' ) ; let min = 0 ; let i ; for ( i = 0 ; i < N ; i ++ ) { if ( S [ i ] == ' ' && i + K <= N ) { for ( let j = i ; j < i + K ; j ++ ) { if ( S [ j ] == ' ' ) S [ j ] = ' ' ; else S [ j ] = ' ' ; } min ++ ; } } for ( i = 0 ; i < N ; i ++ ) { if ( S [ i ] == ' ' ) break ; } if ( i == N ) document . write ( min ) ; else document . write ( - 1 ) ; } let S = " " ; let K = 3 ; let N = S . length ; minOperation ( S , K , N ) ;

Index/key variables: i, j
Accumulator variables: i, j, min
Iterator variables: i, j
Javascript program:
function validInsertionstring ( S1 , S2 ) { let N = S1 . length ; let M = S2 . length ; let st = [ ] ; for ( let i = 0 ; i < N ; i ++ ) { st . push ( S1 [ i ] ) ; if ( S1 [ i ] == S2 [ M - 1 ] ) { let idx = M - 1 ; while ( idx >= 0 ) { if ( st . length == 0 ) { return false ; } let c = st [ st . length - 1 ] ; st . pop ( ) ; if ( c != S2 [ idx ] ) { return false ; } idx -- ; } } } if ( st . length != 0 ) { return false ; } else { return true ; } } let S1 = " " ; let S2 = " " ; validInsertionstring ( S1 , S2 ) ? document . write ( " " ) : document . write ( " " ) ;

Index/key variables: i, idx
Accumulator variables: i, idx
Iterator variables: i
Javascript program:
let MAX = 256 function can_form_palindrome ( arr , n ) { let str = " " ; for ( let i = 0 ; i < n ; i ++ ) { str += toString ( arr [ i ] ) ; } let freq = new Array ( n ) . fill ( 0 ) ; for ( let i = 0 ; i < str . length ; i ++ ) { freq [ str . charCodeAt ( i ) ] ++ ; } let count = 0 ; for ( let i = 0 ; i < MAX ; i ++ ) { if ( freq [ i ] & 1 ) { count ++ ; } if ( count > 1 ) { return false ; } } return true ; } let arr = [ 1 , 2 , 3 , 1 , 2 ] ; let n = arr . length ; can_form_palindrome ( arr , n ) ? document . write ( " " ) : document . write ( " " ) ;

Index/key variables: i
Accumulator variables: count, i, str
Iterator variables: i
Javascript program:
function minimumFlips ( s ) { let n = s . length ; let i ; let cnt0 = 0 ; for ( i = 0 ; i < n ; i ++ ) { if ( s [ i ] == ' ' ) cnt0 ++ ; } let cnt1 = 0 let res = n - cnt0 for ( i = 0 ; i < n ; i ++ ) if ( s [ i ] == ' ' ) { cnt0 -= 1 } else if ( s [ i ] == ' ' ) { res = Math . min ( res , cnt1 + cnt0 ) cnt1 += 1 } return res } S = ' ' document . write ( minimumFlips ( S ) )

Index/key variables: i
Accumulator variables: cnt0, cnt1, i
Iterator variables: i
Javascript program:
function presentSubstring ( s , k ) { let st = new Set ( ) ; let n = s . length ; s = s . split ( " " ) ; for ( let i = 0 ; i < n ; i ++ ) { let s1 = " " ; for ( let j = 0 ; j < k && i + j < n ; j ++ ) { s1 += s [ i + j ] ; st . add ( s1 ) ; } } return st ; } function smallestSubstring ( s , k ) { let st = new Set ( ) ; st = presentSubstring ( s , k ) ; let index = 0 ; for ( let len = 1 ; len <= k ; len ++ ) { let t = new Array ( len ) . fill ( " " ) ; while ( true ) { if ( ! st . has ( t . join ( " " ) ) ) { return t . join ( " " ) ; } index = len - 1 ; while ( index >= 0 && t [ index ] == " " ) { t [ index ] = " " ; index -- ; } if ( index >= 0 ) t [ index ] = String . fromCharCode ( t [ index ] . charCodeAt ( 0 ) + 1 ) ; else break ; } } return " " ; } let s = " " ; let K = 3 ; document . write ( smallestSubstring ( s , K ) ) ;

Index/key variables: index
Accumulator variables: i, index, j, len, s1
Iterator variables: i, j, len
Javascript program:
function maximumK ( S ) { let N = S . length ; let ans = N ; let flag = 0 ; for ( let i = 0 ; i < N - 1 ; i ++ ) { if ( S [ i ] != S [ i + 1 ] ) { flag = 1 ; ans = Math . min ( ans , Math . max ( i + 1 , N - i - 1 ) ) ; } } if ( flag == 0 ) return 0 ; return ans ; } let S = " " ; document . write ( maximumK ( S ) ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function checkhappy ( arr , K , N ) { let visited = new Set ( ) ; for ( let s of arr ) { if ( s [ 0 ] == K ) { if ( visited . has ( s . slice ( 1 ) ) ) return " " ; } else { if ( visited . has ( K + s ) ) return " " ; } visited . add ( s ) ; } return " " ; } let arr = [ " " , " " , " " , " " , " " , " " ] ; let K = " " ; let N = arr . length ; document . write ( checkhappy ( arr , K , N ) ) ;

Iterator variables: s
Javascript program:
function minimumTimeToConvertString ( S , N ) { let upper = 0 , lower = 0 ; for ( let i = 0 ; i < N ; i ++ ) { let c = S [ i ] ; if ( c == c . toUpperCase ( ) ) { upper ++ ; } else { lower ++ ; } } let moves = 0 ; if ( upper > parseInt ( N / 2 , 10 ) ) { let i = 0 ; while ( upper > parseInt ( N / 2 , 10 ) && i < N ) { if ( S [ i ] == S [ i ] . toUpperCase ( ) ) { S [ i ] += String . fromCharCode ( 32 ) ; moves ++ ; upper -- ; lower ++ ; } i ++ ; } } else if ( lower > parseInt ( N / 2 , 10 ) ) { let i = 0 ; while ( lower > parseInt ( N / 2 , 10 ) && i < N ) { if ( S [ i ] == S [ i ] . toLowerCase ( ) ) { S [ i ] = String . fromCharCode ( S [ i ] . charCodeAt ( ) - 32 ) ; moves ++ ; upper ++ ; lower -- ; } i ++ ; } } document . write ( moves + " " ) ; document . write ( S . join ( " " ) ) ; } let S = " " ; let N = S . length ; minimumTimeToConvertString ( S . split ( ' ' ) , N ) ;

Index/key variables: i
Accumulator variables: i, lower, moves, upper
Iterator variables: i
Javascript program:
function zigzag ( s , rows ) { let interval = 2 * rows - 2 ; for ( let i = 0 ; i < rows ; i ++ ) { let step = interval - 2 * i ; for ( let j = i ; j < s . length ; j = j + interval ) { document . write ( s [ j ] ) ; if ( step > 0 && step < interval && step + j < s . length ) { for ( let k = 0 ; k < ( interval - rows - i ) ; k ++ ) document . write ( " " ) ; document . write ( s [ j + step ] ) ; for ( let k = 0 ; k < i - 1 ; k ++ ) document . write ( " " ) ; } else { for ( let k = 0 ; k < ( interval - rows ) ; k ++ ) document . write ( " " ) ; } } document . write ( " " ) ; } } let s = " " + " " + " " ; let rows = 9 ; zigzag ( s , rows ) ;

Index/key variables: j
Accumulator variables: i, k
Iterator variables: i, j, k
Javascript program:
function subString ( s , n ) { let hash = new Map ( ) ; hash . set ( 0 , 1 ) ; let pre = 0 ; let count = 0 ; for ( let i = 0 ; i < n ; i ++ ) { pre ^= ( 1 << s [ i ] . charCodeAt ( 0 ) - 97 ) ; if ( ! hash . has ( pre ) ) hash . set ( pre , 0 ) ; count += ( hash . get ( pre ) ) ; hash . set ( pre , hash . get ( pre ) == null ? 0 : hash . get ( pre ) + 1 ) ; } return count ; } let S = " " ; let N = S . length ; document . write ( subString ( S , N ) ) ;

Index/key variables: i
Accumulator variables: count, i, pre
Iterator variables: i
Javascript program:
function atleastkDistinctChars ( s , k ) { let n = s . length ; let mp = new Map ( ) ; let begin = 0 , end = 0 ; let ans = 0 ; while ( end < n ) { let c = s [ end ] ; if ( mp . has ( c ) ) mp . set ( c , mp . get ( c ) + 1 ) ; else mp . set ( c , 1 ) ; end ++ ; while ( mp . size >= k ) { let pre = s [ begin ] ; mp . set ( pre , mp . get ( pre ) - 1 ) ; if ( mp . get ( pre ) == 0 ) { mp . delete ( pre ) ; } ans += s . length - end + 1 ; begin ++ ; } } document . write ( ans ) ; } let S = " " ; let K = 3 ; atleastkDistinctChars ( S , K ) ;

Index/key variables: begin, end
Accumulator variables: ans, begin, end
Javascript program:
function canSplit ( S ) { let frequency = new Array ( 26 ) . fill ( 0 ) let cnt_singles = 0 let k = 0 for ( let i = 0 ; i < S . length ; i ++ ) { frequency [ S . charCodeAt ( i ) - ' ' . charCodeAt ( 0 ) ] += 1 } let odd = 0 let eve = 0 for ( let i = 0 ; i < 26 ; i ++ ) { if ( frequency [ i ] ) { odd += ( frequency [ i ] & 1 ) } } if ( eve >= odd ) { document . write ( " " ) } else { document . write ( " " ) } } let S = " " canSplit ( S )

Index/key variables: i
Accumulator variables: i, odd
Iterator variables: i
Javascript program:
function getMaxRepetitions ( s1 , n1 , s2 , n2 ) { let temp1 = new Array ( 26 ) ; let temp2 = new Array ( 26 ) ; for ( let i = 0 ; i < 26 ; i ++ ) { temp1 [ i ] = 0 ; temp2 [ i ] = 0 ; } for ( let i = 0 ; i < s1 . split ( " " ) . length ; i ++ ) temp1 [ s1 [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] ++ ; for ( let i = 0 ; i < s2 . split ( " " ) . length ; i ++ ) temp2 [ s2 [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] ++ ; for ( let i = 0 ; i < 26 ; i ++ ) { if ( temp2 [ i ] > temp1 [ i ] ) return 0 ; } let s1_reps = 0 ; let s2_reps = 0 ; let s2_index_to_reps = new Map ( ) ; s2_index_to_reps . set ( 0 , [ 0 , 0 ] ) ; let i = 0 ; let j = 0 ; while ( s1_reps < n1 ) { if ( s1 [ i ] == s2 [ j ] ) j += 1 ; i += 1 ; if ( j == s2 . length ) { j = 0 ; s2_reps += 1 ; } if ( i == s1 . length ) { i = 0 ; s1_reps += 1 ; if ( ! s2_index_to_reps . has ( j ) ) break ; s2_index_to_reps . set ( j , [ s1_reps , s2_reps ] ) ; } } if ( s1_reps == n1 ) return s2_reps / n2 ; let initial_s1_reps = s2_index_to_reps . get ( j ) [ 0 ] , initial_s2_reps = s2_index_to_reps . get ( j ) [ 1 ] ; let loop_s1_reps = s1_reps - initial_s1_reps ; let loop_s2_reps = s2_reps - initial_s2_reps ; let loops = ( n1 - initial_s1_reps ) ; s2_reps = initial_s2_reps + loops * loop_s2_reps ; s1_reps = initial_s1_reps + loops * loop_s1_reps ; while ( s1_reps < n1 ) { if ( s1 [ i ] == s2 [ j ] ) j += 1 ; i += 1 ; if ( i == s1 . length ) { i = 0 ; s1_reps += 1 ; } if ( j == s2 . length ) { j = 0 ; s2_reps += 1 ; } } return s2_reps / n2 ; } let s1 = " " ; let n1 = 4 ; let s2 = " " ; let n2 = 2 ; document . write ( getMaxRepetitions ( s1 , n1 , s2 , n2 ) ) ;

Index/key variables: i, j
Accumulator variables: i, j, s1_reps, s2_reps
Iterator variables: i
Javascript program:
function removeAdjacent ( s ) { if ( s . length == 1 ) return s ; let sb = " " ; for ( let i = 0 ; i < s . length - 1 ; i ++ ) { let c = s [ i ] ; let d = s [ i + 1 ] ; if ( c != d ) { sb = sb + c ; if ( i == s . length - 2 ) { sb = sb + d ; } } else { for ( let j = i + 2 ; j < s . length ; j ++ ) sb = sb + s [ j ] ; return sb ; } } return sb ; } function reduceString ( s ) { let result = " " ; let pre = s ; while ( true ) { result = removeAdjacent ( pre ) ; if ( result == pre ) break ; pre = result ; } if ( result . length != 0 ) document . write ( result ) ; else document . write ( " " ) ; } let S = " " ; reduceString ( S ) ;

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
function minDeletions ( str ) { var fre = new Array ( 26 ) ; fre . fill ( 0 ) ; var n = str . length ; for ( var i = 0 ; i < n ; i ++ ) { fre [ str [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] += 1 ; } var count = 0 ; for ( var i = 0 ; i < 26 ; i ++ ) { if ( fre [ i ] % 2 ) { count += 1 ; } } if ( count == 0 count == 1 ) { return 0 ; } else { return count - 1 ; } } var str = " " ; document . write ( minDeletions ( str ) + " " ) ;

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Javascript program:
function findSubstringInWraproundString ( p ) { let ans = 0 ; let curLen = 0 ; let arr = new Array ( 26 ) ; arr . fill ( 0 ) ; for ( let i = 0 ; i < p . length ; i ++ ) { let curr = p [ i ] . charCodeAt ( ) - ' ' . charCodeAt ( ) ; if ( i > 0 && ( p [ i - 1 ] . charCodeAt ( ) != ( ( curr + 26 - 1 ) % 26 + ' ' . charCodeAt ( ) ) ) ) { curLen = 0 ; } curLen ++ ; if ( curLen > arr [ curr ] ) { ans += ( curLen - arr [ curr ] ) ; arr [ curr ] = curLen ; } } document . write ( ans ) ; } let p = " " ; static void Main ( ) { string p = " " ; findSubstringInWraproundString ( p ) ;

Index/key variables: curr, i
Accumulator variables: ans, curLen, i
Iterator variables: i
Javascript program:
function remove ( N , digit ) { var strN = N . toString ( ) ; var ans = " " ; var i ; for ( i = 0 ; i < strN . length ; i ++ ) { if ( ( strN . charCodeAt ( i ) - 48 ) == digit ) { continue ; } ans += strN [ i ] ; } return parseInt ( ans ) ; } function getMin ( arr ) { var minSum = 1000000000 ; var i , j ; for ( i = 0 ; i < 10 ; i ++ ) { var curSum = 0 ; for ( j = 0 ; j < arr . length ; j ++ ) { curSum += remove ( arr [ j ] , i ) ; } minSum = Math . min ( minSum , curSum ) ; } document . write ( minSum ) ; } var arr = [ 34 , 23 , 85 , 93 ] ; getMin ( arr ) ;

Index/key variables: i, j
Accumulator variables: ans, curSum, i, j
Iterator variables: i, j
Javascript program:
function maxUnique ( S , st ) { var mx = 0 ; for ( var i = 1 ; i <= S . length ; i ++ ) { var tmp = S . substring ( 0 , i ) ; if ( ! st . has ( tmp ) ) { st . add ( tmp ) ; mx = Math . max ( mx , maxUnique ( S . substring ( i ) , st ) + 1 ) ; st . delete ( tmp ) ; } } return mx ; } function maxUniqueSplit ( S ) { var st = new Set ( ) ; return maxUnique ( S , st ) ; } var S = " " ; var res = maxUniqueSplit ( S ) ; document . write ( res ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function removeValidBracketSequences ( str , N ) { let A = [ ] ; let B = [ ] ; let C = [ ] ; let vis = new Array ( N ) ; for ( let i = 0 ; i < N ; i ++ ) { vis [ i ] = true ; } for ( let i = 0 ; i < N ; i ++ ) { if ( str [ i ] == ' ' ) { A . push ( i ) ; } else if ( str [ i ] == ' ' ) { B . push ( i ) ; } else if ( str [ i ] == ' ' ) { C . push ( i ) ; } else if ( str [ i ] == ' ' && ( A . length > 0 ) ) { vis [ A [ A . length - 1 ] ] = false ; A . pop ( ) ; vis [ i ] = false ; } else if ( str [ i ] == ' ' && ( B . length > 0 ) ) { vis [ B [ B . length - 1 ] ] = false ; B . pop ( ) ; vis [ i ] = false ; } else if ( str [ i ] == ' ' && ( C . length > 0 ) ) { vis [ C [ C . length - 1 ] ] = false ; C . pop ( ) ; vis [ i ] = false ; } } for ( let i = 0 ; i < N ; ++ i ) { if ( vis [ i ] ) document . write ( str [ i ] ) ; } } let str = " " ; let N = str . length ; removeValidBracketSequences ( str , N ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function update ( BIT , idx , i , val ) { while ( i < 10005 ) { BIT [ idx ] [ i ] += val ; i = i + ( i & ( - i ) ) ; } } function query ( BIT , idx , i ) { let ans = 0 ; while ( i > 0 ) { ans += BIT [ idx ] [ i ] ; i = i - ( i & ( - i ) ) ; } return ans ; } function maxDiffFreq ( s , queries ) { let BIT = new Array ( 26 ) ; for ( let i = 0 ; i < 26 ; i ++ ) { BIT [ i ] = new Array ( 10005 ) ; for ( let j = 0 ; j < 10005 ; j ++ ) { BIT [ i ] [ j ] = 0 ; } } let n = s . length ; for ( let i = 0 ; i < n ; i ++ ) { update ( BIT , s [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) , i + 1 , 1 ) ; } let Q = queries . length ; for ( let i = 0 ; i < Q ; ++ i ) { let mx = 0 ; let mn = Number . MAX_VALUE ; let l = queries [ i ] [ 0 ] ; let r = queries [ i ] [ 1 ] ; for ( let j = 0 ; j < 26 ; j ++ ) { let p = query ( BIT , j , r ) ; let q = query ( BIT , j , l - 1 ) ; mx = Math . max ( mx , p - q ) ; if ( p > 0 ) { mn = Math . min ( mn , p - q ) ; } } document . write ( mx - mn + " " ) ; } } let S = " " ; let queries = [ [ 2 , 6 ] , [ 1 , 7 ] ] ; maxDiffFreq ( S , queries ) ;

Index/key variables: i, idx, j
Accumulator variables: ans, i, j
Iterator variables: i, j
Javascript program:
function minOperation ( arr , N ) { var cntMinOP = 0 ; var M = arr [ 0 ] . length ; var hash = Array . from ( Array ( 256 ) , ( ) => Array ( M ) . fill ( 0 ) ) ; for ( var i = 0 ; i < N ; i ++ ) { for ( var j = 0 ; j < M ; j ++ ) { hash [ arr [ i ] [ j ] . charCodeAt ( 0 ) ] [ j ] ++ ; } } for ( var i = 0 ; i < M ; i ++ ) { var Sum = 0 ; var Max = 0 ; for ( var j = 0 ; j < 256 ; j ++ ) { Sum += hash [ j ] [ i ] ; Max = Math . max ( Max , hash [ j ] [ i ] ) ; } cntMinOP += ( Sum - Max ) ; } return cntMinOP ; } var arr = [ " " , " " , " " ] ; var N = arr . length ; document . write ( minOperation ( arr , N ) + " " ) ;

Index/key variables: i, j
Accumulator variables: Sum, cntMinOP, i, j
Iterator variables: i, j
Javascript program:
function countStrings ( s , k ) { var ans = 1 ; var len = s . length ; var flag = 0 ; var start_ind ; for ( var i = 0 ; i < len - 1 ; i ++ ) { if ( ( s [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) + s [ i + 1 ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ) == k && flag == 0 ) { flag = 1 ; start_ind = i ; } if ( flag == 1 && ( s [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) + s [ i + 1 ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ) != k ) { flag = 0 ; if ( ( i - start_ind + 1 ) % 2 != 0 ) ans *= ( i - start_ind + 1 - 1 ) / 2 + 1 ; } } if ( flag == 1 && ( len - start_ind ) % 2 != 0 ) ans *= parseInt ( ( len - start_ind ) / 2 ) + 1 ; document . write ( ans ) ; } var S = " " ; var K = 4 ; countStrings ( S , K ) ;

Index/key variables: i
Accumulator variables: ans, i
Iterator variables: i
Javascript program:
function find_num ( n ) { var ans = 0 ; var sumOfDigitsN = 0 ; for ( var c = 0 ; c < n . length ; c ++ ) { sumOfDigitsN += n - ' ' ; } var x = 11 ; while ( true ) { var newNum = x * parseInt ( n ) ; var tempSumDigits = 0 ; var temp = ( newNum . toString ( ) ) ; for ( var c = 0 ; c < temp . length ; c ++ ) { tempSumDigits += temp - ' ' ; } if ( tempSumDigits == sumOfDigitsN ) { ans = x ; break ; } x ++ ; } document . write ( ans ) ; } var N = " " ; find_num ( N ) ;

Accumulator variables: c, sumOfDigitsN, tempSumDigits, x
Iterator variables: c
Javascript program:
function findDisStr ( arr , N ) { let DistString = new Set ( ) ; for ( let i = N - 1 ; i >= 0 ; i -- ) { if ( ! DistString . has ( arr [ i ] ) ) { DistString . add ( arr [ i ] ) ; } } for ( let String of DistString ) { document . write ( String + " " ) ; } } let arr = [ " " , " " , " " , " " , " " ] ; let N = arr . length ; findDisStr ( arr , N ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: String, i
Javascript program:
function modifyString ( A , str , K ) { str = str . split ( " " ) let N = str . length ; let count = new Array ( N + 1 ) . fill ( 0 ) ; for ( let i = 0 ; i < K ; i ++ ) { count [ A [ i ] ] += 1 ; } for ( let i = 1 ; i <= N / 2 ; i ++ ) { count [ i ] = count [ i ] + count [ i - 1 ] ; if ( count [ i ] & 1 ) { let temp = str [ i - 1 ] ; str [ i - 1 ] = str [ N - i ] ; str [ N - i ] = temp } } return str . join ( " " ) ; } let str = " " ; let arr = [ 1 , 2 , 3 ] ; let K = arr . length ; document . write ( modifyString ( arr , str , K ) ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function __gcd ( a , b ) { return b == 0 ? a : __gcd ( b , a % b ) ; } function findFraction ( s ) { let be_deci = " " , af_deci = " " , reccu = " " ; let x = true , y = false , z = false ; for ( let i = 0 ; i < s . length ; ++ i ) { if ( s [ i ] == ' ' ) { x = false ; y = true ; continue ; } if ( s [ i ] == ' ' ) { z = true ; y = false ; continue ; } if ( x ) be_deci += s [ i ] ; if ( y ) af_deci += s [ i ] ; if ( z ) { for ( ; i < s . length && s [ i ] != ' ' ; ++ i ) reccu += s [ i ] ; break ; } } let num_be_deci = parseInt ( be_deci ) ; let num_af_deci = 0 ; if ( af_deci . length != 0 ) num_af_deci = parseInt ( af_deci ) ; let numr = num_be_deci * Math . pow ( 10 , af_deci . length ) + num_af_deci ; let deno = Math . pow ( 10 , af_deci . length ) ; if ( reccu . length == 0 ) { let gd = __gcd ( numr , deno ) ; document . write ( numr / gd + " " + deno / gd ) ; } else { let reccu_num = parseInt ( reccu ) ; let numr1 = numr * Math . pow ( 10 , reccu . length ) + reccu_num ; let deno1 = deno * Math . pow ( 10 , reccu . length ) ; let res_numr = numr1 - numr , res_deno = deno1 - deno ; let gd = __gcd ( res_numr , res_deno ) ; document . write ( res_numr / gd + " " + res_deno / gd ) ; } } let str = " " ; findFraction ( str ) ;

Index/key variables: i
Accumulator variables: af_deci, be_deci, reccu
Iterator variables: i
Boolean variables: x, y, z
Javascript program:
function lexi_largest_String ( a , i , sum , v ) { if ( sum < 0 ) return false ; if ( sum == 0 ) return true ; if ( i < 0 ) return false ; v . push ( i ) ; if ( lexi_largest_String ( a , i , sum - a [ i ] , v ) ) return true ; v . pop ( ) ; return lexi_largest_String ( a , i - 1 , sum , v ) ; } function generateString ( a , sum ) { let v = [ ] ; lexi_largest_String ( a , 25 , sum , v ) ; let s = " " ; for ( let j = 0 ; j < v . length ; j ++ ) s += String . fromCharCode ( v [ j ] + ' ' . charCodeAt ( ) ) ; document . write ( s + " " ) ; } let a = [ 1 , 1 , 2 , 33 , 4 , 6 , 9 , 7 , 36 , 32 , 58 , 32 , 28 , 904 , 22 , 255 , 47 , 69 , 558 , 544 , 21 , 36 , 48 , 85 , 48 , 58 ] ; let sum = 236 ; generateString ( a , sum ) ;

Index/key variables: i, j
Accumulator variables: j, s
Iterator variables: j
Javascript program:
function fact ( a ) { var i , f = 1 ; for ( i = 2 ; i <= a ; i ++ ) f = f * i ; return f ; } function permute ( n , r ) { var ans = 0 ; ans = ( fact ( n ) / fact ( n - r ) ) ; return ans ; } function findPermutations ( n ) { var sum = 0 , P ; for ( var r = 1 ; r <= n ; r ++ ) { P = permute ( n , r ) ; sum = sum + P ; } return sum ; } var str = " " ; var result , n ; n = str . length ; document . write ( findPermutations ( n ) ) ;

Accumulator variables: i, r
Iterator variables: i, r
Javascript program:
function polynomialRollingHash ( str ) { let p = 31 ; let m = ( 1e9 + 9 ) ; let power_of_p = 1 ; let hash_val = 0 ; for ( let i = 0 ; i < str . length ; i ++ ) { hash_val = ( hash_val + ( str [ i ] . charCodeAt ( ) - ' ' . charCodeAt ( ) + 1 ) * power_of_p ) % m ; power_of_p = ( power_of_p * p ) % m ; } return hash_val ; } let str1 = " " ; let str2 = " " ; document . write ( " " + str1 + " " + polynomialRollingHash ( str1 ) ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function firstNonRepElement ( str ) { let list = [ ] ; list . push ( str [ 0 ] ) ; for ( let i = 1 ; i < str . length ; i ++ ) { if ( list . includes ( str [ i ] ) ) list . splice ( list . indexOf ( str [ i ] ) , 1 ) ; else list . push ( str [ i ] ) ; } document . write ( list [ 0 ] ) ; } let str = " " ; firstNonRepElement ( str ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i