dhyuti-n/xlcost-variable-roles huggingface dataset:
Javascript program:
function generateString ( N , M , K ) { let s = " " ; let cnt1 = 0 ; let cnt2 = 0 ; for ( let i = 0 ; i < N ; i ++ ) { cnt1 ++ ; cnt2 ++ ; if ( cnt1 <= M ) { if ( cnt2 <= K ) { s = s + String . fromCharCode ( 96 + cnt1 ) ; } else { s = s + ' ' ; } } else { cnt1 = 1 ; cnt2 = 1 ; s = s + ' ' ; } } return s ; } let N = 7 , M = 5 , K = 3 ; document . write ( generateString ( N , M , K ) )

Accumulator variables: cnt1, cnt2, i
Iterator variables: i
Javascript program:
function finalString ( str ) { let x = 0 , y = 0 ; let left ; let n = str . length ; for ( let i = 0 ; i < n ; i ++ ) { if ( str [ i ] == ' ' ) x ++ ; else y ++ ; } if ( x > y ) left = 1 ; else left = 0 ; let length = n - 2 * Math . min ( x , y ) ; for ( let i = 0 ; i < length ; i ++ ) { document . write ( left ) ; } } let str = " " ; finalString ( str ) ;

Index/key variables: i
Accumulator variables: i, x, y
Iterator variables: i
Javascript program:
function swap ( str , i , j ) { let tempArr = str . split ( " " ) ; let temp = tempArr [ i ] ; tempArr [ i ] = tempArr [ j ] ; tempArr [ j ] = temp ; return ( tempArr ) . join ( " " ) ; } function IsLexicographicallySmaller ( A , B ) { if ( A < ( B ) ) { return true ; } let temp = A ; let p = temp . split ( " " ) ; p . sort ( ) ; temp = ( p ) . join ( " " ) ; let index = - 1 ; for ( let i = 0 ; i < A . length ; i ++ ) { if ( A [ i ] != temp [ i ] ) { index = i ; break ; } } if ( index == - 1 ) { return false ; } let j = 0 ; for ( let i = 0 ; i < A . length ; i ++ ) { if ( A [ i ] == temp [ index ] ) j = i ; } A = swap ( A , index , j ) ; if ( A < ( B ) ) { return true ; } else { return false ; } } let A = " " ; let B = " " ; if ( IsLexicographicallySmaller ( A , B ) ) { document . write ( " " ) ; } else { document . write ( " " ) ; }

Index/key variables: i, index, j
Accumulator variables: i
Iterator variables: i
Javascript program:
function max ( x , y ) { return ( x > y ) ? x : y ; } function longestPalindromic ( str , i , j , count ) { if ( i > j ) return count ; if ( i == j ) return ( count + 1 ) ; if ( str [ i ] == str [ j ] ) { count = longestPalindromic ( str , i + 1 , j - 1 , count + 2 ) ; return max ( count , max ( longestPalindromic ( str , i + 1 , j , 0 ) , longestPalindromic ( str , i , j - 1 , 0 ) ) ) ; } return Math . max ( longestPalindromic ( str , i + 1 , j , 0 ) , longestPalindromic ( str , i , j - 1 , 0 ) ) ; } function longest_palindromic_substr ( str ) { return longestPalindromic ( str , 0 , str . length - 1 , 0 ) ; } let str = " " ; document . write ( longest_palindromic_substr ( str ) ) ;

Index/key variables: i, j
Javascript program:
function MaxPrefix ( s ) { var Dict = { } ; for ( const i of s ) { if ( Dict . hasOwnProperty ( i ) ) { Dict [ i ] ++ ; } else { Dict [ i ] = 1 ; } } var minfrequency = 2147483647 ; for ( const [ key , value ] of Object . entries ( Dict ) ) { minfrequency = Math . min ( minfrequency , value ) ; } var countminFrequency = 0 ; for ( const [ key , value ] of Object . entries ( Dict ) ) { if ( Dict [ key ] === minfrequency ) countminFrequency += 1 ; } var mapper = { } ; var indi = 0 ; for ( const i of s ) { if ( mapper . hasOwnProperty ( i ) ) { mapper [ i ] ++ ; } else { mapper [ i ] = 1 ; } if ( mapper [ i ] > countminFrequency ) break ; indi += 1 ; } document . write ( s . substring ( 0 , indi ) ) ; } var str = " " ; MaxPrefix ( str ) ;

Index/key variables: i, key
Accumulator variables: countminFrequency, indi
Iterator variables: i
Javascript program:
function countSubString ( S , L , n ) { var freq = new Array ( 26 ) . fill ( 0 ) ; var ans = 0 ; for ( var i = 0 ; i < n ; i ++ ) { freq [ L [ i ] . charCodeAt ( 0 ) - " " . charCodeAt ( 0 ) ] = 1 ; } var count = 0 ; for ( const x of S ) { if ( freq [ x . charCodeAt ( 0 ) - " " . charCodeAt ( 0 ) ] > 0 ) { ans = ans + parseInt ( ( count * count + count ) / 2 ) ; count = 0 ; } else count ++ ; } ans += parseInt ( ( count * count + count ) / 2 ) ; return ans ; } var S = " " ; var L = [ " " , " " , " " ] ; var n = L . length ; document . write ( countSubString ( S . split ( " " ) , L , n ) ) ;

Index/key variables: i
Accumulator variables: ans, count, i
Iterator variables: i, x
Javascript program:
function findNthOccur ( str , ch , N ) { var occur = 0 ; for ( var i = 0 ; i < str . length ; i ++ ) { if ( str [ i ] == ch ) { occur += 1 ; } if ( occur == N ) return i ; } return - 1 ; } var str = " " ; var ch = ' ' ; var N = 2 ; document . write ( findNthOccur ( str , ch , N ) ) ;

Index/key variables: i
Accumulator variables: i, occur
Iterator variables: i
Javascript program:
function solve ( X , Y , N , K ) { let count = new Array ( N + 1 ) ; count . fill ( 0 ) ; let sol = 0 ; count [ 0 ] = 0 ; for ( let i = 1 ; i <= N ; i ++ ) { count [ i ] = count [ i - 1 ] + Math . abs ( X [ i - 1 ] . charCodeAt ( ) - Y [ i - 1 ] . charCodeAt ( ) ) ; } let j = 0 ; for ( let i = 1 ; i <= N ; i ++ ) { while ( ( count [ i ] - count [ j ] ) > K ) { j ++ ; } sol = Math . max ( sol , i - j ) ; } return sol ; } let N = 4 ; let X = " " , Y = " " ; let K = 3 ; document . write ( solve ( X , Y , N , K ) ) ;

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i
Javascript program:
function jaro_distance ( s1 , s2 ) { if ( s1 == s2 ) return 1.0 ; let len1 = s1 . length , len2 = s2 . length ; if ( len1 == 0 len2 == 0 ) return 0.0 ; let max_dist = Math . floor ( Math . max ( len1 , len2 ) / 2 ) - 1 ; let match = 0 ; let hash_s1 = new Array ( s1 . length ) ; hash_s1 . fill ( 0 ) ; let hash_s2 = new Array ( s2 . length ) ; hash_s2 . fill ( 0 ) ; for ( let i = 0 ; i < len1 ; i ++ ) { for ( let j = Math . max ( 0 , i - max_dist ) ; j < Math . min ( len2 , i + max_dist + 1 ) ; j ++ ) if ( s1 [ i ] == s2 [ j ] && hash_s2 [ j ] == 0 ) { hash_s1 [ i ] = 1 ; hash_s2 [ j ] = 1 ; match ++ ; break ; } } if ( match == 0 ) return 0.0 ; let t = 0 ; let point = 0 ; for ( let i = 0 ; i < len1 ; i ++ ) if ( hash_s1 [ i ] == 1 ) { while ( hash_s2 [ point ] == 0 ) point ++ ; if ( s1 [ i ] != s2 [ point ++ ] ) t ++ ; } t /= 2 ; return ( ( match ) / ( len1 ) + ( match ) / ( len2 ) + ( match - t ) / ( match ) ) / 3.0 ; } function jaro_Winkler ( s1 , s2 ) { let jaro_dist = jaro_distance ( s1 , s2 ) ; if ( jaro_dist > 0.7 ) { let prefix = 0 ; for ( let i = 0 ; i < Math . min ( s1 . length , s2 . length ) ; i ++ ) { if ( s1 [ i ] == s2 [ i ] ) prefix ++ ; else break ; } prefix = Math . min ( 4 , prefix ) ; jaro_dist += 0.1 * prefix * ( 1 - jaro_dist ) ; } return jaro_dist . toFixed ( 6 ) ; } let s1 = " " , s2 = " " ; document . write ( " " + jaro_Winkler ( s1 , s2 ) ) ;

Index/key variables: i, j, point
Accumulator variables: i, j, jaro_dist, match, point, prefix, t
Iterator variables: i, j
Javascript program:
function isWordPresent ( sentence , word ) { let s = sentence . split ( " " ) ; for ( let temp = 0 ; temp < s . length ; temp ++ ) { if ( s [ temp ] == ( word ) ) { return true ; } } return false ; } let s = " " ; let word = " " ; if ( isWordPresent ( s , word ) ) document . write ( " " ) ; else document . write ( " " ) ;

Index/key variables: temp
Accumulator variables: temp
Iterator variables: temp
Javascript program:
function isWordPresent ( sentence , word ) { word = transform ( word ) ; sentence = transform ( sentence ) ; let s = sentence . split ( " " ) ; for ( let temp = 0 ; temp < s . length ; temp ++ ) { if ( s [ temp ] == ( word ) ) { return true ; } } return false ; } function transform ( word ) { return word . toUpperCase ( ) ; } let s = " " ; let word = " " ; if ( isWordPresent ( s , word ) ) document . write ( " " ) ; else document . write ( " " ) ;

Index/key variables: temp
Accumulator variables: temp
Iterator variables: temp
Javascript program:
function countChars ( str , n ) { let i = 0 , cnt = 0 ; while ( i < n ) { if ( str [ i ] == ' ' ) i += 1 ; else i += 2 ; cnt += 1 ; } return cnt ; } let str = " " ; let n = str . length ; document . write ( countChars ( str , n ) ) ;

Index/key variables: i
Accumulator variables: cnt, i
Javascript program:
let MAX = 26 ; function compressString ( s , n ) { let freq = new Array ( MAX ) ; freq . fill ( 0 ) ; for ( let i = 0 ; i < n ; i ++ ) { freq [ s [ i ] . charCodeAt ( ) - ' ' . charCodeAt ( ) ] ++ ; } for ( let i = 0 ; i < MAX ; i ++ ) { if ( freq [ i ] == 0 ) continue ; document . write ( String . fromCharCode ( i + ' ' . charCodeAt ( ) ) + " " + freq [ i ] ) ; } } let s = " " ; let n = s . length ; compressString ( s , n ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function decBinary ( arr , n ) { let k = parseInt ( Math . log ( n ) / Math . log ( 2 ) , 10 ) ; while ( n > 0 ) { arr [ k -- ] = n % 2 ; n = parseInt ( n / 2 , 10 ) ; } } function binaryDec ( arr , n ) { let ans = 0 ; for ( let i = 0 ; i < n ; i ++ ) ans += arr [ i ] << ( n - i - 1 ) ; return ans ; } function concat ( m , n ) { let k = parseInt ( Math . log ( m ) / Math . log ( 2 ) , 10 ) + 1 ; let l = parseInt ( Math . log ( n ) / Math . log ( 2 ) , 10 ) + 1 ; let a = new Array ( k ) ; let b = new Array ( l ) ; let c = new Array ( k + l ) ; decBinary ( a , m ) ; decBinary ( b , n ) ; let iN = 0 ; for ( let i = 0 ; i < k ; i ++ ) c [ iN ++ ] = a [ i ] ; for ( let i = 0 ; i < l ; i ++ ) c [ iN ++ ] = b [ i ] ; return ( binaryDec ( c , k + l ) ) ; } let m = 4 , n = 5 ; document . write ( concat ( m , n ) ) ;

Index/key variables: i
Accumulator variables: ans, i, iN, k
Iterator variables: i
Javascript program:
function addZeros ( str , n ) { for ( let i = 0 ; i < n ; i ++ ) { str = " " + str ; } return str ; } function getXOR ( a , b ) { let aLen = a . length ; let bLen = b . length ; if ( aLen > bLen ) { a = addZeros ( b , aLen - bLen ) ; } else if ( bLen > aLen ) { a = addZeros ( a , bLen - aLen ) ; } let len = Math . max ( aLen , bLen ) ; let res = " " ; for ( let i = 0 ; i < len ; i ++ ) { if ( a [ i ] == b [ i ] ) res += " " ; else res += " " ; } return res ; } let a = " " , b = " " ; document . write ( getXOR ( a , b ) ) ;

Index/key variables: i
Accumulator variables: i, res
Iterator variables: i
Javascript program:
var MAX = 26 ; function minOperation ( str , len ) { var first = Array ( MAX ) . fill ( - 1 ) ; var last = Array ( MAX ) . fill ( - 1 ) ; for ( var i = 0 ; i < len ; i ++ ) { var index = ( str [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ) ; if ( first [ index ] == - 1 ) first [ index ] = i ; last [ index ] = i ; } var minOp = - 1 ; for ( var i = 0 ; i < MAX ; i ++ ) { if ( first [ i ] == - 1 first [ i ] == last [ i ] ) continue ; var cnt = len - ( last [ i ] - first [ i ] + 1 ) ; if ( minOp == - 1 cnt < minOp ) minOp = cnt ; } return minOp ; } var str = " " ; var len = str . length ; document . write ( minOperation ( str , len ) ) ;

Index/key variables: i, index
Accumulator variables: i
Iterator variables: i
Javascript program:
let N = 2 ; function isVowel ( ch ) { return ( ch == ' ' ch == ' ' ch == ' ' ch == ' ' ch == ' ' ) ; } function countVowels ( str , l , r ) { let cnt = 0 ; for ( let i = l ; i <= r ; i ++ ) { if ( isVowel ( str [ i ] ) ) cnt ++ ; } return cnt ; } function performQueries ( str , queries , q ) { for ( let i = 0 ; i < q ; i ++ ) { document . write ( countVowels ( str , queries [ i ] [ 0 ] , queries [ i ] [ 1 ] ) + " " ) ; } } let str = " " ; let queries = [ [ 1 , 3 ] , [ 2 , 4 ] , [ 1 , 9 ] ] ; let q = queries . length ; performQueries ( str , queries , q ) ;

Index/key variables: i
Accumulator variables: cnt, i
Iterator variables: i
Javascript program:
class node { constructor ( ) { this . data = ' ' ; this . next = null ; } } function add ( data ) { let newnode = new node ( ) ; newnode . data = data ; newnode . next = null ; return newnode ; } function string_to_SLL ( text , head ) { head = add ( text [ 0 ] ) ; let curr = head ; for ( let i = 1 ; i < text . length ; i ++ ) { curr . next = add ( text [ i ] ) ; curr = curr . next ; } return head ; } function print ( head ) { let curr = head ; while ( curr != null ) { document . write ( curr . data + " " ) ; curr = curr . next ; } } let text = " " ; let head = null ; head = string_to_SLL ( text , head ) ; print ( head ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: node
Javascript program:
function minLength ( str , len ) { let s = [ ] ; for ( let i = 0 ; i < len ; i ++ ) { if ( s . length == 0 ) { s . push ( str [ i ] ) ; } else { let c = s [ s . length - 1 ] ; if ( c != str [ i ] && c . toUpperCase ( ) == str [ i ] . toUpperCase ( ) ) { s . pop ( ) ; } else { s . push ( str [ i ] ) ; } } } return s . length ; } ' ' ' ' ' ' let str = " " ; let len = str . length ; document . write ( minLength ( str , len ) ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
let MAX = 26 ; function canBeMadeEqual ( str1 , str2 ) { let len1 = str1 . length ; let len2 = str2 . length ; if ( len1 == len2 ) { let freq = new Array ( MAX ) ; freq . fill ( 0 ) ; for ( let i = 0 ; i < len1 ; i ++ ) { freq [ str1 [ i ] . charCodeAt ( ) - ' ' . charCodeAt ( ) ] ++ ; } for ( let i = 0 ; i < len2 ; i ++ ) { if ( freq [ str2 [ i ] . charCodeAt ( ) - ' ' . charCodeAt ( ) ] > 0 ) return true ; } } return false ; } let str1 = " " , str2 = " " ; if ( canBeMadeEqual ( str1 , str2 ) ) document . write ( " " ) ; else document . write ( " " ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function getCount ( str , n ) { var cnt = 0 ; var i = 0 ; while ( i < n - 2 ) { if ( str [ i ] === str [ i + 1 ] && str [ i ] === str [ i + 2 ] ) { cnt ++ ; i = i + 2 ; } else { i ++ ; } } return cnt ; } var str = " " ; var n = str . length ; document . write ( getCount ( str , n ) ) ;

Index/key variables: i
Accumulator variables: cnt, i
Javascript program:
function fact ( n ) { let fact = 1 ; for ( let i = 1 ; i <= n ; i ++ ) fact *= i ; return fact ; } function countStrings ( str , n ) { let distinct_char = new Set ( ) ; for ( let i = 0 ; i < n ; i ++ ) { distinct_char . add ( str [ i ] ) ; } return fact ( distinct_char . size ) ; } let str = " " ; let n = str . length ; document . write ( countStrings ( str , n ) ) ;

Index/key variables: i
Accumulator variables: fact, i
Iterator variables: i
Javascript program:
function getChar ( str ) { let sum = 0 ; for ( let i = 0 ; i < str . length ; i ++ ) { sum += ( str [ i ] . charCodeAt ( ) - ' ' . charCodeAt ( ) + 1 ) ; } if ( sum % 26 == 0 ) return ' ' ; else { sum = sum % 26 ; return String . fromCharCode ( ' ' . charCodeAt ( ) + sum - 1 ) ; } } let str = " " ; document . write ( getChar ( str ) ) ;

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Javascript program:
function reverse ( str , len , l , r ) { if ( l < 0 r >= len l > r ) return " " ; while ( l < r ) { let c = str [ l ] ; str [ l ] = str [ r ] ; str [ r ] = c ; l ++ ; r -- ; } return str . join ( " " ) ; } let str = " " ; let len = str . length ; let l = 5 , r = 7 ; document . write ( reverse ( str . split ( ' ' ) , len , l , r ) ) ;

Index/key variables: l, r
Accumulator variables: l, r
Javascript program:
function encrypt ( input ) { let evenPos = ' ' , oddPos = ' ' ; let repeat , ascii ; for ( let i = 0 ; i < input . length ; i ++ ) { ascii = input [ i ] . charCodeAt ( ) ; repeat = ascii >= 97 ? ascii - 96 : ascii - 64 ; for ( let j = 0 ; j < repeat ; j ++ ) { if ( i % 2 == 0 ) document . write ( oddPos ) ; else document . write ( evenPos ) ; } } } let input = [ ' ' , ' ' , ' ' , ' ' ] ; encrypt ( input ) ;

Index/key variables: i
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
function IsRedundantBraces ( A ) { let a = 0 , b = 0 ; for ( let i = 0 ; i < A . length ; i ++ ) { if ( A [ i ] == ' ' && A [ i + 2 ] == ' ' ) return true ; if ( A [ i ] == ' ' A [ i ] == ' ' A [ i ] == ' ' A [ i ] == ' ' ) a ++ ; if ( A [ i ] == ' ' ) b ++ ; } if ( b > a ) return true ; return false ; } let A = " " ; if ( IsRedundantBraces ( A ) ) { document . write ( " " ) ; } else { document . write ( " " ) ; }

Index/key variables: i
Accumulator variables: a, b, i
Iterator variables: i
Javascript program:
function balancedBrackets ( str ) { var dep = 0 ; var minDep = 0 ; for ( var i = 0 ; i < str . length ; i ++ ) { if ( str [ i ] === " " ) dep ++ ; else dep -- ; if ( minDep > dep ) minDep = dep ; } if ( minDep < 0 ) { for ( var i = 0 ; i < Math . abs ( minDep ) ; i ++ ) str = " " + str ; } dep = 0 ; for ( var i = 0 ; i < str . length ; i ++ ) { if ( str [ i ] === " " ) dep ++ ; else dep -- ; } if ( dep !== 0 ) { for ( var i = 0 ; i < dep ; i ++ ) str = str + " " ; } return str ; } var str = " " ; document . write ( balancedBrackets ( str ) ) ;

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

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Javascript program:
function find_digit ( s , n ) { var first_digit = - 1 ; for ( var i = n - 1 ; i >= 0 ; i -- ) { if ( s [ i ] < ' ' s [ i ] > ' ' ) { first_digit = i ; break ; } } first_digit ++ ; var s_len = first_digit ; var num = 0 , pw = 1 ; var i = n - 1 ; while ( i >= 0 ) { if ( s [ i ] >= ' ' && s [ i ] <= ' ' ) { var digit = s [ i ] - ' ' ; num = num + ( pw * digit ) ; if ( num >= s_len ) return - 1 ; pw = pw * 10 ; } i -- ; } num = num * 10 ; var req = s_len - num ; if ( req > 9 req < 0 ) return - 1 ; return req ; } var s = " " ; var n = s . length ; document . write ( find_digit ( s , n ) ) ;

Index/key variables: i
Accumulator variables: first_digit, i
Iterator variables: i
Javascript program:
function canConvert ( str1 , str2 ) { var i = 0 , j = 0 ; while ( i < str1 . length && j < str2 . length ) { if ( str1 [ i ] !== str2 [ j ] ) { if ( str1 [ i ] === " " && str2 [ j ] === " " && i + 1 < str1 . length && str1 [ i + 1 ] === " " ) { i += 2 ; j ++ ; } else { return false ; } } else { i ++ ; j ++ ; } } if ( i === str1 . length && j === str2 . length ) return true ; return false ; } var str1 = " " , str2 = " " ; if ( canConvert ( str1 , str2 ) ) document . write ( " " ) ; else document . write ( " " ) ;

Index/key variables: i, j
Accumulator variables: i, j
Javascript program:
function reverse ( s ) { let stc = [ ] ; let temp = " " ; for ( let i = 0 ; i < s . length ; i ++ ) { if ( s [ i ] == ' ' ) { stc . push ( temp ) ; temp = " " ; } else { temp = temp + s [ i ] ; } } stc . push ( temp ) ; while ( stc . length != 0 ) { temp = stc [ stc . length - 1 ] ; document . write ( temp + " " ) ; stc . pop ( ) ; } } let s = " " ; reverse ( s ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function printMatrix ( n , m ) { if ( n < 5 m < 5 ) { document . write ( - 1 ) ; return ; } var s = " " ; for ( var i = 0 ; i < n ; i ++ ) { for ( j = 0 ; j < m ; j ++ ) { document . write ( s [ j % 5 ] + " " ) ; } document . write ( " " ) ; var c = s [ 0 ] ; s = s . substring ( 1 , s . length ) + s . substring ( 0 , 1 ) ; s [ 4 ] = c ; } } var n = 5 , m = 5 ; printMatrix ( n , m ) ;

Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
function isTwoAlter ( s ) { for ( let i = 0 ; i < s . length - 2 ; i ++ ) { if ( s [ i ] != s [ i + 2 ] ) { return false ; } } if ( s [ 0 ] == s [ 1 ] ) return false ; return true ; } let str = " " ; if ( isTwoAlter ( str ) ) document . write ( " " ) ; else document . write ( " " ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function minOperations ( n , a , b , c ) { let ans = 0 ; for ( let i = 0 ; i < n ; i ++ ) { let x = a [ i ] ; let y = b [ i ] ; let z = c [ i ] ; if ( x == y && y == z ) { ; } else if ( x == y y == z x == z ) { ans ++ ; } else { ans += 2 ; } } return ans ; } let a = " " ; let b = " " ; let c = " " ; let n = a . length ; document . write ( minOperations ( n , a , b , c ) ) ;

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

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function countSubStr ( str , n , x ) { let res = 0 , count = 0 ; for ( let i = 0 ; i < n ; i ++ ) { if ( str [ i ] == x ) { res += ( ( count + 1 ) * ( n - i ) ) ; count = 0 ; } else count ++ ; } return res ; } let str = " " ; let n = str . length ; let x = ' ' ; document . write ( countSubStr ( str , n , x ) ) ;

Index/key variables: i
Accumulator variables: count, i, res
Iterator variables: i
Javascript program:
function countSubstrings ( s , c ) { var n = s . length ; var cnt = 0 ; var sum = 0 ; for ( i = 0 ; i < n ; i ++ ) { if ( s . charAt ( i ) != c ) cnt ++ ; else { sum += ( cnt * ( cnt + 1 ) ) / 2 ; cnt = 0 ; } } sum += ( cnt * ( cnt + 1 ) ) / 2 ; return sum ; } var s = " " ; var c = ' ' ; document . write ( countSubstrings ( s , c ) ) ;

Accumulator variables: cnt, i, sum
Iterator variables: i
Javascript program:
function getMinimizedSum ( str , len ) { var i , maxVal = - 2147483648 , sum = 0 ; var occurrences = new Array ( 26 ) . fill ( 0 ) ; for ( i = 0 ; i < len ; i ++ ) { occurrences [ str [ i ] . charCodeAt ( 0 ) - " " . charCodeAt ( 0 ) ] ++ ; sum += str [ i ] . charCodeAt ( 0 ) ; } for ( i = 0 ; i < 26 ; i ++ ) { maxVal = Math . max ( maxVal , occurrences [ i ] * ( i + " " . charCodeAt ( 0 ) ) ) ; } return sum - maxVal ; } var str = " " ; var len = str . length ; document . write ( getMinimizedSum ( str , len ) ) ;

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Javascript program:
function isPalindrome ( s ) { let i = 0 ; let j = s . length - 1 ; while ( i < j ) { if ( s [ i ] != s [ j ] ) return false ; i ++ ; j -- ; } return true ; } function getIndex ( S1 , S2 , n ) { let S = " " ; for ( let i = 0 ; i < n ; i ++ ) { S = S + S1 [ i ] ; let Temp = " " ; for ( let j = i + 1 ; j < n ; j ++ ) Temp += S2 [ j ] ; if ( isPalindrome ( S + Temp ) ) { return i ; } } return - 1 ; } let S1 = " " , S2 = " " ; let n = S1 . length ; document . write ( getIndex ( S1 , S2 , n ) ) ;

Index/key variables: i, j
Accumulator variables: Temp, i, j
Iterator variables: i, j
Javascript program:
function isPalindrome ( s , i , j ) { while ( i < j ) { if ( s [ i ] != s [ j ] ) return false ; i ++ ; j -- ; } return true ; } function getIndex ( s1 , s2 , len ) { let i = 0 , j = len - 1 ; while ( i < j ) { if ( s1 [ i ] != s2 [ j ] ) { break ; } i ++ ; j -- ; } if ( i == j ) { return i - 1 ; } else if ( isPalindrome ( s2 , i , j ) ) return i - 1 ; else if ( isPalindrome ( s1 , i , j ) ) return j ; return - 1 ; } let s1 = " " , s2 = " " ; let len = s1 . length ; document . write ( getIndex ( s1 , s2 , len ) + " " ) ;

Index/key variables: i, j
Accumulator variables: i, j
Javascript program:
function count_acronym ( n , arr ) { let freq = new Array ( 26 ) ; freq . fill ( 0 ) ; for ( let i = 0 ; i < n ; i ++ ) freq [ arr [ i ] [ 0 ] . charCodeAt ( ) - ' ' . charCodeAt ( ) ] ++ ; let cnt = 0 ; for ( let i = 0 ; i < n ; i ++ ) { let st = arr [ i ] ; let num = new Array ( 26 ) ; num . fill ( 0 ) ; for ( let j = 0 ; j < st . length ; j ++ ) num [ st [ j ] . charCodeAt ( ) - ' ' . charCodeAt ( ) ] ++ ; let flag = true ; for ( let j = 1 ; j < 26 ; j ++ ) { if ( num [ j ] > freq [ j ] ) { flag = false ; break ; } } let x = st [ 0 ] . charCodeAt ( ) - ' ' . charCodeAt ( ) ; if ( freq [ x ] - 1 < num [ x ] ) flag = false ; if ( flag ) cnt ++ ; } return cnt ; } let arr = [ " " , " " , " " , " " , " " ] ; let n = arr . length ; document . write ( count_acronym ( n , arr ) ) ;

Index/key variables: i, j, x
Accumulator variables: cnt, i, j
Iterator variables: i, j
Boolean variables: flag