dhyuti-n/xlcost-variable-roles huggingface dataset:
Javascript program:
function isPossible ( S , R , N ) { var cntl = 0 , cntr = 0 ; var cntu = 0 , cntd = 0 ; for ( var i = 0 ; i < N ; i ++ ) { if ( S [ i ] == ' ' ) cntl ++ ; else if ( S [ i ] == ' ' ) cntr ++ ; else if ( S [ i ] == ' ' ) cntu ++ ; else cntd ++ ; } if ( Math . max ( Math . max ( cntl , cntr ) , Math . max ( cntu , cntd ) ) >= R ) return " " ; var mp = new Map ( ) ; var r_square = R * R ; for ( var i = 1 ; i * i <= r_square ; i ++ ) { mp . set ( i * i , i ) ; if ( mp . has ( r_square - i * i ) ) { if ( Math . max ( cntl , cntr ) >= mp . get ( r_square - i * i ) && Math . max ( cntu , cntd ) >= i ) return " " ; if ( Math . max ( cntl , cntr ) >= i && Math . max ( cntu , cntd ) >= mp . get ( r_square - i * i ) ) return " " ; } } return " " ; } var S = " " ; var R = 5 ; var N = S . length ; document . write ( isPossible ( S , R , N ) ) ;

Index/key variables: i
Accumulator variables: cntd, cntl, cntr, cntu, i
Iterator variables: i
Javascript program:
function addASCII ( S , N ) { var newStr = new Array ( S . length ) ; for ( var i = 0 ; i < S . length ; i ++ ) { var a = N [ i ] . charCodeAt ( 0 ) - " " . charCodeAt ( 0 ) ; var b = S [ i ] . charCodeAt ( 0 ) + a ; if ( b > 122 ) b -= 26 ; newStr [ i ] = String . fromCharCode ( b ) ; } document . write ( newStr . join ( " " ) ) ; } var S = " " , N = " " ; addASCII ( S , N ) ;

Index/key variables: i
Accumulator variables: b, i
Iterator variables: i
Javascript program:
function findMinimumChairs ( s ) { var count = 0 ; var i = 0 ; var mini = - 2147483647 ; while ( i < s . length ) { if ( s [ i ] == ' ' ) count ++ ; else count -- ; mini = Math . max ( count , mini ) ; i ++ ; } return mini ; } var s = " " ; document . write ( findMinimumChairs ( s ) ) ;

Index/key variables: i
Accumulator variables: count, i
Javascript program:
function fillString ( str , k ) { var s = str . split ( " " ) ; var mp = { } ; for ( var i = 0 ; i < s . length ; i ++ ) { if ( s [ i ] !== " " ) { mp [ i % k ] = s [ i ] ; } } for ( var i = 0 ; i < s . length ; i ++ ) { if ( ! mp . hasOwnProperty ( i % k ) ) { document . write ( - 1 ) ; return ; } s [ i ] = mp [ i % k ] ; } document . write ( s . join ( " " ) + " " ) ; } var S = " " ; var K = 4 ; fillString ( S , K ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function rearrangeString ( s1 , s2 ) { let cnt = new Array ( 26 ) ; cnt . fill ( 0 ) ; for ( let i = 0 ; i < s2 . length ; i ++ ) cnt [ s2 [ i ] . charCodeAt ( ) - ' ' . charCodeAt ( ) ] ++ ; let unique = 0 ; for ( let i = 0 ; i < 26 ; i ++ ) if ( cnt [ i ] != 0 ) unique ++ ; if ( unique == 1 ) { let count_in_s2 = s2 . length ; let count_in_s1 = 0 ; for ( let i = 0 ; i < s1 . length ; i ++ ) if ( s1 [ i ] == s2 [ 0 ] ) count_in_s1 ++ ; if ( count_in_s1 < count_in_s2 ) { document . write ( s1 . join ( " " ) ) ; return ; } document . write ( - 1 ) ; } else { let inc = 1 ; for ( let i = 0 ; i < s2 . length - 1 ; i ++ ) if ( s2 [ i ] . charCodeAt ( ) > s2 [ i + 1 ] . charCodeAt ( ) ) inc = 0 ; if ( inc == 1 ) { s1 . sort ( ) ; s1 . reverse ( ) ; document . write ( s1 . join ( " " ) ) ; } else { s1 . sort ( ) ; document . write ( s1 . join ( " " ) ) ; } } } let s1 = " " . split ( ' ' ) ; let s2 = " " . split ( ' ' ) ; rearrangeString ( s1 , s2 ) ;

Index/key variables: i
Accumulator variables: count_in_s1, i, unique
Iterator variables: i
Javascript program:
function isReducible ( str ) { let N = str . length ; let s = [ ] ; for ( let i = 0 ; i < N ; i ++ ) { if ( str [ i ] == ' ' ) s . push ( str [ i ] ) ; else if ( s . length > 0 ) s . pop ( ) ; else return false ; } if ( s . length == 0 ) { return true ; } else { return false ; } } let str = " " ; if ( isReducible ( str ) ) document . write ( " " ) ; else document . write ( " " ) ;

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

Index/key variables: i
Accumulator variables: cntOp, i
Iterator variables: i
Javascript program:
function solution ( s ) { var vowel = [ ] , consonant = [ ] ; s . split ( ' ' ) . forEach ( i => { if ( i == ' ' i == ' ' i == ' ' i == ' ' i == ' ' ) { vowel . push ( i ) ; } else { consonant . push ( i ) ; } } ) ; var Nc , Nv ; Nv = vowel . length ; Nc = consonant . length ; var M = parseInt ( Nc / ( Nv - 1 ) ) ; var ans = " " ; var consotnant_till = 0 ; vowel . forEach ( i => { ans += i ; var temp = 0 ; for ( var j = consotnant_till ; j < Math . min ( Nc , consotnant_till + M ) ; j ++ ) { ans += consonant [ j ] ; temp ++ ; } consotnant_till += temp ; } ) ; return ans ; } var str = " " ; document . write ( solution ( str ) ) ;

Index/key variables: j
Accumulator variables: ans, consotnant_till, j, temp
Iterator variables: j
Javascript program:
function smallestlexicographicstring ( s , k ) { let n = s . length ; if ( k >= n ) { for ( let i = 0 ; i < n ; i ++ ) { s [ i ] = ' ' ; } document . write ( s ) ; return ; } for ( let i = 0 ; i < n ; i ++ ) { if ( k == 0 ) { break ; } if ( s [ i ] == ' ' ) continue ; for ( let j = i + 1 ; j < n ; j ++ ) { if ( s [ j ] . charCodeAt ( ) > s [ i ] . charCodeAt ( ) ) { s [ j ] = s [ i ] ; break ; } else if ( j == n - 1 ) s [ j ] = s [ i ] ; } s [ i ] = ' ' ; k -- ; } document . write ( s . join ( " " ) ) ; } let s = ( " " ) . split ( ' ' ) ; let k = 6 ; smallestlexicographicstring ( s , k ) ;

Index/key variables: i, j
Accumulator variables: i, j, k
Iterator variables: i, j
Javascript program:
function canReduceString ( S , N ) { var count_1 = 0 ; var count_2 = 0 ; for ( var i = 0 ; i < N ; i ++ ) { if ( S [ i ] === " " ) { count_1 ++ ; } else { count_2 ++ ; } } if ( count_1 === 0 count_2 === 0 ) { document . write ( " " + " " ) ; } else if ( count_1 === count_2 ) { document . write ( " " + " " ) ; } else if ( N % 2 !== 0 ) { document . write ( " " ) ; } else { document . write ( Math . abs ( count_1 - count_2 ) / 2 ) ; } } var S = " " ; var N = S . length ; canReduceString ( S , N ) ;

Index/key variables: i
Accumulator variables: count_1, count_2, i
Iterator variables: i
Javascript program:
function isAcceptedDFA ( s , N ) { var count = 0 ; for ( var i = 0 ; i < N ; i ++ ) { if ( s [ i ] === " " ) count ++ ; } if ( count === N && count !== 0 ) { document . write ( " " ) ; } else { document . write ( " " ) ; } } var S = " " ; isAcceptedDFA ( S , S . length ) ;

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Javascript program:
function maximum_pallindromic ( arr ) { var res = 0 ; var c1 = 0 , c2 = 0 ; for ( var i = 0 ; i < 26 ; i ++ ) { res += parseInt ( arr [ i ] / 3 ) ; arr [ i ] = ( arr [ i ] % 3 ) ; if ( arr [ i ] == 1 ) c1 ++ ; else if ( arr [ i ] == 2 ) c2 ++ ; } res += Math . min ( c1 , c2 ) ; var t = Math . min ( c1 , c2 ) ; c1 -= t ; c2 -= t ; res += 2 * parseInt ( c2 / 3 ) ; c2 %= 3 ; res += parseInt ( c2 / 2 ) ; document . write ( res ) ; } var arr = [ 4 , 5 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ] ; maximum_pallindromic ( arr ) ;

Index/key variables: i
Accumulator variables: c1, c2, i, res
Iterator variables: i
Javascript program:
function find_Winner ( arr , N ) { var Q = Array . from ( Array ( N ) , ( ) => Array ( ) ) var M = arr . length ; for ( var i = 0 ; i < M ; i ++ ) { var len = arr [ i ] . length ; for ( var j = 0 ; j < len ; j ++ ) { Q [ i ] . push ( arr [ i ] [ j ] - 1 ) ; } } var player = 0 ; while ( Q [ player ] . length > 0 ) { var nextPlayer = Q [ player ] [ 0 ] - ' ' ; Q [ player ] . shift ( ) ; player = nextPlayer ; } document . write ( " " + ( player + 1 ) ) ; } var N = 3 ; var arr = [ " " , " " , " " ] ; find_Winner ( arr , N ) ;

Index/key variables: i, j, player
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
function longestSubstring ( s ) { let dp = new Array ( 1024 ) . fill ( 1 ) ; let res = 0 , mask = 0 ; dp [ 0 ] = - 1 ; for ( let i = 0 ; i < s . length ; ++ i ) { mask ^= 1 << ( s [ i ] - ' ' ) ; res = Math . max ( res , i - dp [ mask ] ) ; for ( let j = 0 ; j <= 9 ; ++ j ) res = Math . max ( res , i - dp [ mask ^ ( 1 << j ) ] ) ; dp [ mask ] = Math . min ( dp [ mask ] , i ) ; } return res ; } let s = " " ; document . write ( longestSubstring ( s ) ) ;

Index/key variables: i, mask
Accumulator variables: mask
Iterator variables: i, j
Javascript program:
function Validate ( M ) { let len = M . length ; let temp = " " ; for ( let i = 0 ; i < len ; i ++ ) { if ( ! isNaN ( parseInt ( M [ i ] ) ) ) temp += M [ i ] ; } let nwlen = temp . length ; if ( nwlen != 10 ) { document . write ( " " ) ; return ; } let res = " " ; let x = temp . substring ( 0 , 3 ) ; res += " " + x + " " ; x = temp . substring ( 3 , 6 ) ; res += " " + x + " " ; x = temp . substring ( 6 , 9 ) ; res += " " + x + " " ; x = temp . substring ( 9 , 10 ) ; res += " " + x + " " ; document . write ( res + " " ) ; } let M = " " ; Validate ( M ) ;

Index/key variables: i
Accumulator variables: i, res, temp
Iterator variables: i
Javascript program:
function hexaModK ( s , k ) { var mp = new Map ( ) ; for ( var i = 1 ; i <= 9 ; i ++ ) { mp . set ( String . fromCharCode ( i + ' ' . charCodeAt ( 0 ) ) , i ) ; } mp . set ( ' ' , 10 ) ; mp . set ( ' ' , 11 ) ; mp . set ( ' ' , 12 ) ; mp . set ( ' ' , 13 ) ; mp . set ( ' ' , 14 ) ; mp . set ( ' ' , 15 ) ; var m = parseInt ( k , 16 ) ; var base = 1 ; var ans = 0 ; for ( var i = s . length - 1 ; i >= 0 ; i -- ) { var n = mp . get ( s [ i ] ) % m ; ans = ( ans + ( base % m * n % m ) % m ) % m ; base = ( base % m * 16 % m ) % m ; } document . write ( ans . toString ( 16 ) . toUpperCase ( ) ) ; } var n = " " ; var k = " " ; hexaModK ( n , k ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
var combination = " " ; var combinations = [ ] ; function printSequences ( combinations ) { for ( var s of combinations ) { document . write ( s + " " ) ; } } function generateCombinations ( s , n ) { for ( var i = 0 ; i < s . length ; i ++ ) { combination += s [ i ] ; var x = parseInt ( combination ) ; if ( x <= n ) { combinations . push ( combination ) ; generateCombinations ( s , n ) ; } combination = combination . substring ( 0 , combination . length - 1 ) ; } } var S = " " ; var N = 100 ; generateCombinations ( S , N ) ; printSequences ( combinations ) ;

Index/key variables: i
Accumulator variables: combination, i
Iterator variables: i, s
Javascript program:
function compute_hash ( str ) { let p = 31 ; let MOD = 1e9 + 7 ; let hash_val = 0 ; let mul = 1 ; for ( let i = 0 ; i < str . length ; i ++ ) { let ch = str [ i ] ; hash_val = ( hash_val + ( ch . charCodeAt ( ) - ' ' . charCodeAt ( ) + 1 ) * mul ) % MOD ; mul = ( mul * p ) % MOD ; } return hash_val ; } function distinct_str ( arr , n ) { let hash = new Array ( n ) ; for ( let i = 0 ; i < n ; i ++ ) { hash [ i ] = compute_hash ( arr [ i ] ) ; } hash . sort ( function ( a , b ) { return a - b } ) ; let cntElem = 1 ; for ( let i = 1 ; i < n ; i ++ ) { if ( hash [ i ] != hash [ i - 1 ] ) { cntElem ++ ; } } return cntElem ; } let arr = [ " " , " " , " " , " " ] ; let N = arr . length ; document . write ( distinct_str ( arr , N ) ) ;

Index/key variables: i
Accumulator variables: cntElem, i
Iterator variables: i
Javascript program:
function SieveOfEratosthenes ( prime , n ) { for ( let i = 0 ; i <= n ; i ++ ) { prime [ i ] = true ; } prime [ 0 ] = prime [ 1 ] = false ; for ( let i = 2 ; i * i <= n ; i ++ ) { if ( prime [ i ] == true ) { for ( let j = 2 ; i * j <= n ; j ++ ) { prime [ i * j ] = false ; } } } } function removePrimeFrequencies ( s ) { var n = s . length ; var prime = new Array ( n + 1 ) ; SieveOfEratosthenes ( prime , n ) ; var m = { } ; for ( let i = 0 ; i < s . length ; i ++ ) m [ s [ i ] ] = 0 ; for ( let i = 0 ; i < s . length ; i ++ ) { m [ s [ i ] ] ++ ; } var new_string = " " ; for ( let i = 0 ; i < s . length ; i ++ ) { if ( prime [ m [ s [ i ] ] ] ) continue ; new_string += s [ i ] ; } console . log ( new_string ) ; } str = " " ; removePrimeFrequencies ( str ) ;

Index/key variables: i
Accumulator variables: i, j, new_string
Iterator variables: i, j
Javascript program:
function rearrange ( s ) { let s1 = " " , s2 = " " , ans = " " ; let s3 = s . split ( " " ) ; for ( let x = 0 ; x < s3 . length ; x ++ ) { if ( s3 [ x ] >= ' ' && s3 [ x ] <= ' ' ) s1 += s3 [ x ] ; else s2 += s3 [ x ] ; } let n = s1 . length ; let m = s2 . length ; if ( Math . abs ( n - m ) > 1 ) return " " ; let i = 0 , j = 0 , k = 0 ; let flag = ( n >= m ) ? 1 : 0 ; while ( i < n && j < m ) { if ( flag != 0 ) ans += s1 [ i ++ ] ; else ans += s2 [ j ++ ] ; if ( flag == 1 ) flag = 0 ; else flag = 1 ; } return ans ; } let str = " " ; document . write ( rearrange ( str ) + " " ) ;

Index/key variables: x
Accumulator variables: ans, i, j, s1, s2, x
Iterator variables: x
Javascript program:
function charactersCount ( str , n ) { let count = 0 ; while ( n > 0 ) { let cur = str [ 0 ] . charCodeAt ( ) ; let ind = 0 ; for ( let j = 1 ; j < n ; j ++ ) { if ( str [ j ] . charCodeAt ( ) < cur ) { cur = str [ j ] . charCodeAt ( ) ; ind = j ; } } str = str . substring ( 0 , ind ) + str . substring ( ind + 1 ) ; n -- ; count += ind + 1 ; } document . write ( count + " " ) ; } let str = " " ; let n = 5 ; charactersCount ( str , n ) ;

Index/key variables: j
Accumulator variables: count, j, n
Iterator variables: j
Javascript program:
function printMiddleCharacter ( str ) { let len = str . length ; let middle = parseInt ( len / 2 , 10 ) ; document . write ( str [ middle ] ) ; } let str = " " ; printMiddleCharacter ( str ) ;

Index/key variables: middle
Javascript program:
function check ( s ) { let a = new Set ( ) ; for ( let i = 0 ; i < s . length ; i ++ ) { if ( a . has ( s [ i ] ) ) { return false ; } a . add ( s [ i ] ) ; } return true ; } function helper ( arr , ind ) { let fin = [ ] ; fin . push ( " " ) ; if ( ind == arr . length ) return fin ; let tmp = helper ( arr , ind + 1 ) ; let ret = tmp ; for ( let i = 0 ; i < tmp . length ; i ++ ) { let test = tmp [ i ] + arr [ ind ] ; if ( check ( test ) ) ret . push ( test ) ; } return ret ; } function maxLength ( arr ) { let tmp = helper ( arr , 0 ) ; let len = 0 ; for ( let i = 0 ; i < tmp . length ; i ++ ) { len = len > tmp [ i ] . length ? len : tmp [ i ] . length ; } return len ; } let s = [ ] ; s . push ( " " ) ; document . write ( maxLength ( s ) ) ;

Index/key variables: i, ind
Accumulator variables: i
Iterator variables: i
Javascript program:
function Range_sum_query ( S , Query ) { var N = S . length ; var A = Array ( N ) ; A [ 0 ] = S [ 0 ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) + 1 ; for ( var i = 1 ; i < N ; i ++ ) { A [ i ] = S [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) + 1 ; A [ i ] = A [ i ] + A [ i - 1 ] ; } for ( var i = 0 ; i < Query . length ; i ++ ) { if ( Query [ i ] [ 0 ] == 1 ) { document . write ( A [ ( Query [ i ] [ 1 ] ) - 1 ] + " " ) ; } else { document . write ( A [ ( Query [ i ] [ 1 ] ) - 1 ] - A [ ( Query [ i ] [ 0 ] ) - 2 ] + " " ) ; } } } var S = " " ; var Query = [ ] ; Query . push ( [ 2 , 4 ] ) ; Query . push ( [ 1 , 3 ] ) ; Range_sum_query ( S , Query ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function swap_ ( a , l , i ) { let temp ; temp = a [ l ] ; a [ l ] = a [ i ] ; a [ i ] = temp ; } function permute ( str , l , r , n ) { let i ; if ( l == r ) { let j = parseInt ( ( str ) . join ( " " ) ) ; if ( j % n == 0 ) document . write ( ( str ) . join ( " " ) + " " ) ; return ; } for ( i = l ; i < r ; i ++ ) { swap_ ( str , l , i ) ; permute ( str , l + 1 , r , n ) ; swap_ ( str , l , i ) ; } } let str = " " ; let n = 5 ; let len = str . length ; if ( len > 0 ) permute ( str . split ( " " ) , 0 , len , n ) ;

Index/key variables: i, l
Accumulator variables: i
Iterator variables: i
Javascript program:
function decimalToBinary ( N ) { var ans = " " ; while ( N > 0 ) { if ( N % 2 == 1 ) { ans = ' ' + ans ; } else { ans = ' ' + ans ; } N = parseInt ( N / 2 ) ; } return ans ; } function checkBinaryString ( str , N ) { var map = Array ( N + 10 ) . fill ( 0 ) , cnt = 0 ; for ( var i = N ; i > 0 ; i -- ) { if ( ! map [ i ] ) { var t = i ; var s = decimalToBinary ( t ) ; if ( str . includes ( s ) ) { while ( t > 0 && map [ t ] == 0 ) { map [ t ] = 1 ; cnt ++ ; t >>= 1 ; } } } } for ( var i = 0 ; i < str . length ; i ++ ) { if ( str [ i ] == ' ' ) { cnt ++ ; break ; } } if ( cnt == N + 1 ) return " " ; else return " " ; } var str = " " ; var N = 3 ; document . write ( checkBinaryString ( str , N ) ) ;

Index/key variables: i, t
Accumulator variables: cnt, i
Iterator variables: i
Javascript program:
function largestAnagramGrp ( arr ) { var prime = [ 2 , 3 , 5 , 7 , 11 , 13 , 17 , 19 , 23 , 29 , 31 , 37 , 41 , 43 , 47 , 53 , 59 , 61 , 67 , 71 , 73 , 79 , 83 , 89 , 97 , 101 , ] ; var max = - 1 ; var maxpdt = - 1 ; var W = { } ; var P = { } ; for ( const temp of arr ) { var c = temp . split ( " " ) ; var pdt = 1 ; for ( const t of c ) { pdt *= prime [ t . charCodeAt ( 0 ) - " " . charCodeAt ( 0 ) ] ; } if ( P . hasOwnProperty ( pdt ) ) { P [ pdt ] = P [ pdt ] + 1 ; } else { W [ pdt ] = temp ; P [ pdt ] = 1 ; } } for ( const [ key , value ] of Object . entries ( P ) ) { if ( max < value ) { max = value ; maxpdt = key ; } } return W [ maxpdt ] ; } var S = " " + " " ; var arr = S . split ( " " ) ; document . write ( largestAnagramGrp ( arr ) ) ;

Index/key variables: maxpdt, pdt
Accumulator variables: pdt
Iterator variables: t, temp
Javascript program:
function print_next_vovel_string ( st ) { var m = { } ; m [ " " ] = 0 ; m [ " " ] = 1 ; m [ " " ] = 2 ; m [ " " ] = 3 ; m [ " " ] = 4 ; var arr = [ " " , " " , " " , " " , " " ] ; var N = st . length ; for ( let i = 0 ; i < N ; i ++ ) { var c = st [ i ] ; if ( c === " " c === " " c === " " c === " " c === " " ) { index = m [ st [ i ] ] + 1 ; newindex = index % 5 ; st = st . replace ( st [ i ] , arr [ newindex ] ) ; } } return st ; } var st = " " ; document . write ( print_next_vovel_string ( st ) ) ;

Index/key variables: i, newindex
Accumulator variables: i
Iterator variables: i
Javascript program:
function isPalindrome ( str ) { let len = str . length ; for ( let i = 0 ; i < len ; i ++ ) { if ( str [ i ] != str [ len - i - 1 ] ) return false ; } return true ; } function isCompressablePalindrome ( str ) { let len = str . length ; let compressed = " " ; compressed = str [ 0 ] ; for ( let i = 1 ; i < len ; i ++ ) { if ( str [ i ] != str [ i - 1 ] ) compressed += str [ i ] ; } return isPalindrome ( compressed ) ; } let str = " " ; if ( isCompressablePalindrome ( str ) ) document . write ( " " + " " ) ; else document . write ( " " ) ;

Index/key variables: i
Accumulator variables: compressed, i
Iterator variables: i
Javascript program:
function isvowel ( x ) { return ( x == ' ' x == ' ' x == ' ' x == ' ' x == ' ' ) ; } function CountTotal ( str ) { let ans = 0 ; let n = str . length ; let s = str . split ( ' ' ) ; let cnt = 0 ; for ( let i = 0 ; i < n ; i ++ ) { if ( isvowel ( s [ i ] ) ) cnt += 1 ; else { ans += ( cnt * ( cnt + 1 ) / 2 ) ; cnt = 0 ; } } if ( cnt != 0 ) ans += ( cnt * ( cnt + 1 ) / 2 ) ; return ans ; } let s = " " ; document . write ( CountTotal ( s ) ) ;

Index/key variables: i
Accumulator variables: ans, cnt, i
Iterator variables: i
Javascript program:
let totCount ; let firstCount ; function getTotCount ( num ) { totCount = 1 ; firstCount = 1 ; let temp = 1 ; while ( ( num & temp ) == 0 ) { temp = temp << 1 ; totCount += 1 ; } firstCount = totCount ; temp = num >> totCount ; while ( temp != 0 ) { totCount += 1 ; temp = temp >> 1 ; } } function flipBitsFromRightMostSetBit ( num ) { getTotCount ( num ) ; let num1 = num ^ ( ( 1 << totCount ) - 1 ) ; num1 = num1 ^ ( ( 1 << firstCount ) - 1 ) ; return num1 ; } let n = 120 ; document . write ( flipBitsFromRightMostSetBit ( n ) ) ;

Accumulator variables: totCount
Javascript program:
function isVowel ( x ) { return x === " " || x === " " || x === " " || x === " " || x === " " ; } function findMaxLen ( s ) { var maxLen = 0 ; var cur ; if ( isVowel ( s [ 0 ] ) ) maxLen = 1 ; cur = maxLen ; for ( var i = 1 ; i < s . length ; i ++ ) { if ( isVowel ( s [ i ] ) ) { if ( s [ i ] !== s [ i - 1 ] ) cur += 1 ; else cur = 1 ; } else { cur = 0 ; } maxLen = Math . max ( cur , maxLen ) ; } return maxLen ; } var Str = " " ; document . write ( findMaxLen ( Str ) ) ;

Index/key variables: i
Accumulator variables: cur, i
Iterator variables: i
Javascript program:
var freq = Array ( 26 ) . fill ( 0 ) ; function checkPalindrome ( ) { var oddCnt = 0 ; freq . forEach ( x => { if ( x % 2 == 1 ) oddCnt ++ ; } ) ; return oddCnt <= 1 ; } function countPalindromePermutation ( s , k ) { for ( var i = 0 ; i < k ; i ++ ) { freq [ s [ i ] . charCodeAt ( 0 ) - 97 ] ++ ; } var ans = 0 ; if ( checkPalindrome ( ) ) { ans ++ ; } var i = 0 , j = k ; while ( j < s . length ) { freq [ s [ i ++ ] . charCodeAt ( 0 ) - 97 ] -- ; freq [ s [ j ++ ] . charCodeAt ( 0 ) - 97 ] ++ ; if ( checkPalindrome ( ) ) { ans ++ ; } } return ans ; } var str = " " ; var K = 3 ; document . write ( countPalindromePermutation ( str , K ) ) ;

Index/key variables: i
Accumulator variables: ans, i, j, oddCnt
Iterator variables: i
Javascript program:
function minFlips ( target ) { let curr = ' ' ; let count = 0 ; for ( let i = 0 ; i < target . length ; i ++ ) { if ( target [ i ] == curr ) { count ++ ; curr = String . fromCharCode ( 48 + ( curr . charCodeAt ( ) + 1 ) % 2 ) ; } } return count ; } let S = " " ; document . write ( minFlips ( S ) ) ;

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Javascript program:
function checkSuffix ( A , B ) { let digit_B = parseInt ( Math . log10 ( B ) + 1 , 10 ) ; A -= B ; return ( A % ( Math . pow ( 10 , digit_B ) ) > 0 ) ; } let A = 12345 , B = 45 ; let result = checkSuffix ( A , B ) ; if ( ! result ) { document . write ( " " ) ; } else { document . write ( " " ) ; }

Accumulator variables: A
Javascript program:
function count_min_length ( s ) { var hash = new Array ( 26 ) . fill ( 0 ) ; var ans = 2147483648 ; for ( var i = 0 ; i < 26 ; i ++ ) hash [ i ] = - 1 ; for ( var i = 0 ; i < s . length ; i ++ ) { if ( hash [ s [ i ] . charCodeAt ( 0 ) - " " . charCodeAt ( 0 ) ] == - 1 ) hash [ s [ i ] . charCodeAt ( 0 ) - " " . charCodeAt ( 0 ) ] = i ; else { if ( hash [ s [ i ] . charCodeAt ( 0 ) - " " . charCodeAt ( 0 ) ] == i - 1 || hash [ s [ i ] . charCodeAt ( 0 ) - " " . charCodeAt ( 0 ) ] == i - 2 ) return 0 ; ans = Math . min ( ans , i - hash [ s [ i ] . charCodeAt ( 0 ) - " " . charCodeAt ( 0 ) ] - 1 ) ; hash [ s [ i ] . charCodeAt ( 0 ) - " " . charCodeAt ( 0 ) ] = i ; } } if ( ans === 2147483648 ) return - 1 ; return ans ; } var str = " " ; document . write ( count_min_length ( str ) ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function rec ( a , i ) { if ( i == 0 ) { document . write ( a . join ( " " ) ) ; return ; } if ( a [ i ] == ' ' ) { let j = i ; while ( a [ j ] != ' \0 ' && a [ j + 1 ] != ' \0 ' ) { let temp = a [ j ] ; a [ j ] = a [ j + 1 ] ; a [ j + 1 ] = temp ; j ++ ; } } rec ( a , i - 1 ) ; } let a = [ ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' \0 ' ] ; let n = 10 ; rec ( a , n - 1 ) ;

Index/key variables: i, j
Accumulator variables: j
Javascript program:
function largestCharacter ( str ) { let uppercase = new Array ( 26 ) ; uppercase . fill ( false ) ; let lowercase = new Array ( 26 ) ; lowercase . fill ( false ) ; let arr = str . split ( ' ' ) ; for ( let c = 0 ; c < arr . length ; c ++ ) { if ( arr == arr . toLowerCase ( ) ) lowercase [ arr . charCodeAt ( ) - 97 ] = true ; if ( arr == arr . toUpperCase ( ) ) uppercase [ arr . charCodeAt ( ) - 65 ] = true ; } for ( let i = 25 ; i >= 0 ; i -- ) { if ( uppercase [ i ] && lowercase [ i ] ) return String . fromCharCode ( i + ' ' . charCodeAt ( ) ) + " " ; } return " " ; } let str = " " ; document . write ( largestCharacter ( str ) ) ;

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