dhyuti-n/xlcost-variable-roles huggingface dataset:
Javascript program:
function isPossible ( a , n ) { if ( n <= 2 ) return true ; var flag = 0 ; for ( i = 0 ; i < n - 2 ; i ++ ) { if ( ! ( a [ i ] > a [ i + 1 ] && a [ i + 1 ] > a [ i + 2 ] ) ) { flag = 1 ; break ; } } if ( flag == 0 ) return true ; flag = 0 ; for ( i = 0 ; i < n - 2 ; i ++ ) { if ( ! ( a [ i ] < a [ i + 1 ] && a [ i + 1 ] < a [ i + 2 ] ) ) { flag = 1 ; break ; } } if ( flag == 0 ) return true ; var val1 = Number . MAX_VALUE , mini = - 1 , val2 = Number . MIN_VALUE , maxi = 0 ; for ( i = 0 ; i < n ; i ++ ) { if ( a [ i ] < val1 ) { mini = i ; val1 = a [ i ] ; } if ( a [ i ] > val2 ) { maxi = i ; val2 = a [ i ] ; } } flag = 1 ; for ( i = 0 ; i < maxi ; i ++ ) { if ( a [ i ] > a [ i + 1 ] ) { flag = 0 ; break ; } } if ( flag == 1 && maxi + 1 == mini ) { flag = 1 ; for ( i = mini ; i < n - 1 ; i ++ ) { if ( a [ i ] > a [ i + 1 ] ) { flag = 0 ; break ; } } if ( flag == 1 ) return true ; } flag = 1 ; for ( i = 0 ; i < mini ; i ++ ) { if ( a [ i ] < a [ i + 1 ] ) { flag = 0 ; break ; } } if ( flag == 1 && maxi - 1 == mini ) { flag = 1 ; for ( i = maxi ; i < n - 1 ; i ++ ) { if ( a [ i ] < a [ i + 1 ] ) { flag = 0 ; break ; } } if ( flag == 1 ) return true ; } return false ; } var a = [ 4 , 5 , 6 , 2 , 3 ] ; var n = a . length ; if ( isPossible ( a , n ) ) document . write ( " " ) ; else document . write ( " " ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function cntRotations ( s , n ) { let str = s + s ; let pre = new Array ( 2 * n ) ; pre . fill ( 0 ) ; for ( let i = 0 ; i < 2 * n ; i ++ ) { if ( i != 0 ) pre [ i ] += pre [ i - 1 ] ; if ( str [ i ] == ' ' str [ i ] == ' ' str [ i ] == ' ' str [ i ] == ' ' str [ i ] == ' ' ) { pre [ i ] ++ ; } } let ans = 0 ; for ( let i = n - 1 ; i < 2 * n - 1 ; i ++ ) { let r = i , l = i - n ; let x1 = pre [ r ] ; if ( l >= 0 ) x1 -= pre [ l ] ; r = i - parseInt ( n / 2 , 10 ) ; let left = pre [ r ] ; if ( l >= 0 ) left -= pre [ l ] ; let right = x1 - left ; if ( left > right ) { ans ++ ; } } return ans ; } let s = " " ; let n = s . length ; document . write ( cntRotations ( s , n ) ) ;

Index/key variables: i, l, r
Accumulator variables: ans, i, left, x1
Iterator variables: i
Javascript program:
function cntRotations ( s , n ) { let lh = 0 , rh = 0 , i , ans = 0 ; for ( i = 0 ; i < parseInt ( n / 2 , 10 ) ; ++ i ) if ( s [ i ] == ' ' s [ i ] == ' ' s [ i ] == ' ' s [ i ] == ' ' s [ i ] == ' ' ) { lh ++ ; } for ( i = parseInt ( n / 2 , 10 ) ; i < n ; ++ i ) if ( s [ i ] == ' ' s [ i ] == ' ' s [ i ] == ' ' s [ i ] == ' ' s [ i ] == ' ' ) { rh ++ ; } if ( lh > rh ) ans ++ ; for ( i = 1 ; i < n ; ++ i ) { if ( s [ i - 1 ] == ' ' s [ i - 1 ] == ' ' s [ i - 1 ] == ' ' s [ i - 1 ] == ' ' s [ i - 1 ] == ' ' ) { rh ++ ; lh -- ; } if ( s [ ( i - 1 + n / 2 ) % n ] == ' ' || s [ ( i - 1 + n / 2 ) % n ] == ' ' || s [ ( i - 1 + n / 2 ) % n ] == ' ' || s [ ( i - 1 + n / 2 ) % n ] == ' ' || s [ ( i - 1 + n / 2 ) % n ] == ' ' ) { rh -- ; lh ++ ; } if ( lh > rh ) ans ++ ; } return ans ; } let s = [ ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' ] ; let n = s . length ; document . write ( cntRotations ( s , n ) ) ;

Index/key variables: i
Accumulator variables: ans, lh, rh
Iterator variables: i
Javascript program:
var size = 2 ; function performQueries ( str , n , queries , q ) { var ptr = 0 ; for ( var i = 0 ; i < q ; i ++ ) { if ( queries [ i ] [ 0 ] == 1 ) { ptr = ( ptr + queries [ i ] [ 1 ] ) % n ; } else { var k = queries [ i ] [ 1 ] ; var index = ( ptr + k - 1 ) % n ; document . write ( str [ index ] + " " ) ; } } } var str = " " ; var n = str . length ; var queries = [ [ 1 , 2 ] , [ 2 , 2 ] , [ 1 , 4 ] , [ 2 , 7 ] ] ; var q = queries . length ; performQueries ( str , n , queries , q ) ;

Index/key variables: i, index
Accumulator variables: i
Iterator variables: i
Javascript program:
function ReverseArray ( arr , left , right ) { var temp ; while ( left < right ) { temp = arr [ left ] ; arr [ left ] = arr [ right ] ; arr [ right ] = temp ; left ++ ; right -- ; } } function RotateAndCheck ( str1 , str2 , d ) { if ( str1 . length !== str2 . length ) return false ; var left_rot_str1 = [ ] ; var right_rot_str1 = [ ] ; var left_flag = true , right_flag = true ; var str1_size = str1 . length ; for ( var i = 0 ; i < str1_size ; i ++ ) { left_rot_str1 . push ( str1 [ i ] ) ; right_rot_str1 . push ( str1 [ i ] ) ; } ReverseArray ( left_rot_str1 , 0 , d - 1 ) ; ReverseArray ( left_rot_str1 , d , str1_size - 1 ) ; ReverseArray ( left_rot_str1 , 0 , str1_size - 1 ) ; ReverseArray ( right_rot_str1 , 0 , str1_size - d - 1 ) ; ReverseArray ( right_rot_str1 , str1_size - d , str1_size - 1 ) ; ReverseArray ( right_rot_str1 , 0 , str1_size - 1 ) ; for ( var i = 0 ; i < str1_size ; i ++ ) { if ( left_rot_str1 [ i ] !== str2 [ i ] ) { left_flag = false ; } if ( right_rot_str1 [ i ] !== str2 [ i ] ) { right_flag = false ; } } if ( left_flag right_flag ) return true ; return false ; } var str1 = " " ; var str2 = " " ; var d = 2 ; d = d % str1 . length ; if ( RotateAndCheck ( str1 , str2 , d ) ) document . write ( " " ) ; else document . write ( " " ) ;

Index/key variables: i, left, right
Accumulator variables: i, left, right
Iterator variables: i
Boolean variables: left_flag, right_flag
Javascript program:
function countOddRotations ( n ) { var odd_count = 0 , even_count = 0 ; do { var digit = n % 10 ; if ( digit % 2 == 1 ) odd_count ++ ; else even_count ++ ; n = parseInt ( n / 10 ) ; } while ( n != 0 ) ; document . write ( " " + odd_count + " " ) ; document . write ( " " + even_count + " " ) ; } var n = 1234 ; countOddRotations ( n ) ;

Accumulator variables: even_count, odd_count
Javascript program:
function numberOfDigits ( n ) { let cnt = 0 ; while ( n > 0 ) { cnt ++ ; n = parseInt ( n / 10 , 10 ) ; } return cnt ; } function cal ( num ) { let digits = numberOfDigits ( num ) ; let powTen = Math . pow ( 10 , digits - 1 ) ; for ( let i = 0 ; i < digits - 1 ; i ++ ) { let firstDigit = parseInt ( num / powTen , 10 ) ; let left = ( ( num * 10 ) + firstDigit ) - ( firstDigit * powTen * 10 ) ; document . write ( left + " " ) ; num = left ; } } let num = 1445 ; cal ( num ) ;

Accumulator variables: cnt, i
Iterator variables: i
Javascript program:
function CheckKCycles ( n , s ) { var ff = true ; var x = 0 ; for ( i = 1 ; i < n ; i ++ ) { x = ( s . substring ( i ) + s . substring ( 0 , i ) ) . length ; if ( x >= s . length ) { continue ; } ff = false ; break ; } if ( ff ) { document . write ( " " ) ; } else { document . write ( " " ) ; } } var n = 3 ; var s = " " ; CheckKCycles ( n , s ) ;

Accumulator variables: i
Iterator variables: i
Boolean variables: ff
Javascript program:
class ListNode { constructor ( ) { this . data = 0 ; this . next = null ; } } function rotateSubList ( A , m , n , k ) { var size = n - m + 1 ; if ( k > size ) { k = k % size ; } if ( k == 0 k == size ) { var head = A ; while ( head != null ) { document . write ( head . data ) ; head = head . next ; } return ; } var link = null ; if ( m == 1 ) { link = A ; } var c = A ; var count = 0 ; var end = null ; var pre = null ; while ( c != null ) { count ++ ; if ( count == m - 1 ) { pre = c ; link = c . next ; } if ( count == n - k ) { if ( m == 1 ) { end = c ; A = c . next ; } else { end = c ; pre . next = c . next ; } } if ( count == n ) { var d = c . next ; c . next = link ; end . next = d ; var head = A ; while ( head != null ) { document . write ( head . data + " " ) ; head = head . next ; } return ; } c = c . next ; } } function push ( head , val ) { var new_node = new ListNode ( ) ; new_node . data = val ; new_node . next = head ; head = new_node ; return head ; } var head = null ; head = push ( head , 70 ) ; head = push ( head , 60 ) ; head = push ( head , 50 ) ; head = push ( head , 40 ) ; head = push ( head , 30 ) ; head = push ( head , 20 ) ; head = push ( head , 10 ) ; var tmp = head ; document . write ( " " ) ; while ( tmp != null ) { document . write ( tmp . data + " " ) ; tmp = tmp . next ; } document . write ( " " ) ; var m = 3 , n = 6 , k = 2 ; document . write ( " " ) ; rotateSubList ( head , m , n , k ) ;

Accumulator variables: count
Class/struct names: ListNode
Javascript program:
function rightRotationDivisor ( N ) { let lastDigit = N % 10 ; let rightRotation = ( lastDigit * Math . pow ( 10 , Math . floor ( ( Math . log10 ( N ) ) ) ) + Math . floor ( N / 10 ) ) ; return ( rightRotation % N == 0 ) ; } function generateNumbers ( m ) { for ( let i = Math . floor ( Math . pow ( 10 , ( m - 1 ) ) ) ; i < Math . floor ( Math . pow ( 10 , m ) ) ; i ++ ) if ( rightRotationDivisor ( i ) ) document . write ( i + " " ) ; } let m = 3 ; generateNumbers ( m ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function generateNumbers ( m ) { let numbers = [ ] ; let k_max , x ; for ( let y = 0 ; y < 10 ; y ++ ) { k_max = Math . floor ( ( Math . pow ( 10 , m - 2 ) * ( 10 * y + 1 ) ) / Math . floor ( Math . pow ( 10 , m - 1 ) + y ) ) ; for ( let k = 1 ; k <= k_max ; k ++ ) { x = Math . floor ( ( y * ( Math . pow ( 10 , m - 1 ) - k ) ) / ( 10 * k - 1 ) ) ; if ( Math . floor ( ( y * ( Math . pow ( 10 , m - 1 ) - k ) ) % ( 10 * k - 1 ) ) == 0 ) numbers . push ( 10 * x + y ) ; } } numbers . sort ( function ( a , b ) { return a - b ; } ) ; for ( let i = 0 ; i < numbers . length ; i ++ ) document . write ( numbers [ i ] + " " ) ; } let m = 3 ; generateNumbers ( m ) ;

Index/key variables: i
Accumulator variables: i, k, y
Iterator variables: i, k, y
Javascript program:
let minIndex = - 1 ; for ( let i = 0 ; i < n ; i ++ ) { if ( arr [ i ] < minEle ) { minEle = arr [ i ] ; minIndex = i ; } } let flag1 = true ; for ( let i = 1 ; i < minIndex ; i ++ ) { if ( arr [ i ] < arr [ i - 1 ] ) { flag1 = false ; break ; } } let flag2 = true ; for ( let i = minIndex + 1 ; i < n ; i ++ ) { if ( arr [ i ] < arr [ i - 1 ] ) { flag2 = false ; break ; } } if ( flag1 && flag2 && ( arr [ n - 1 ] < arr [ 0 ] ) ) document . write ( " " ) ; else document . write ( " " ) ; } let arr = [ 3 , 4 , 5 , 1 , 2 ] ; let n = arr . length ; checkIfSortRotated ( arr , n ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Boolean variables: flag1, flag2
Javascript program:
var N = 4 ; function rotate90Clockwise ( arr ) { for ( j = 0 ; j < N ; j ++ ) { for ( i = N - 1 ; i >= 0 ; i -- ) document . write ( arr [ i ] [ j ] + " " ) ; document . write ( " " ) ; } } var arr = [ [ 1 , 2 , 3 , 4 ] , [ 5 , 6 , 7 , 8 ] , [ 9 , 10 , 11 , 12 ] , [ 13 , 14 , 15 , 16 ] ] ; rotate90Clockwise ( arr ) ;

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
let N = 4 function rotate ( arr ) { for ( let i = 0 ; i < N ; ++ i ) { for ( let j = 0 ; j < i ; ++ j ) { let temp = arr [ i ] [ j ] ; arr [ i ] [ j ] = arr [ j ] [ i ] ; arr [ j ] [ i ] = temp ; } } for ( let i = 0 ; i < N ; ++ i ) { for ( let j = 0 ; j < N / 2 ; ++ j ) { let temp = arr [ i ] [ j ] ; arr [ i ] [ j ] = arr [ i ] [ N - j - 1 ] ; arr [ i ] [ N - j - 1 ] = temp ; } } } function print ( arr ) { for ( let i = 0 ; i < N ; ++ i ) { for ( let j = 0 ; j < N ; ++ j ) document . write ( arr [ i ] [ j ] + " " ) ; document . write ( " " ) ; } } let arr = [ [ 1 , 2 , 3 , 4 ] , [ 5 , 6 , 7 , 8 ] , [ 9 , 10 , 11 , 12 ] , [ 13 , 14 , 15 , 16 ] ] ; rotate ( arr ) ; print ( arr ) ;

Index/key variables: i, j
Iterator variables: i, j
Javascript program:
function occurredOnce ( arr , n ) { arr . sort ( function ( a , b ) { return a - b ; } ) ; if ( arr [ 0 ] != arr [ 1 ] ) document . write ( arr [ 0 ] + " " ) ; for ( let i = 1 ; i < n - 1 ; i ++ ) if ( arr [ i ] != arr [ i + 1 ] && arr [ i ] != arr [ i - 1 ] ) document . write ( arr [ i ] + " " ) ; if ( arr [ n - 2 ] != arr [ n - 1 ] ) document . write ( arr [ n - 1 ] + " " ) ; } let arr = [ 7 , 7 , 8 , 8 , 9 , 1 , 1 , 4 , 2 , 2 ] ; let n = arr . length ; occurredOnce ( arr , n ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function occurredOnce ( arr , n ) { let mp = new Map ( ) ; for ( let i = 0 ; i < n ; i ++ ) { if ( mp . has ( arr [ i ] ) ) mp . set ( arr [ i ] , 1 + mp . get ( arr [ i ] ) ) ; else mp . set ( arr [ i ] , 1 ) ; } for ( let [ key , value ] of mp . entries ( ) ) { if ( value == 1 ) document . write ( key + " " ) ; } } let arr = [ 7 , 7 , 8 , 8 , 9 , 1 , 1 , 4 , 2 , 2 ] ; let n = arr . length ; occurredOnce ( arr , n ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function occurredOnce ( arr , n ) { var i = 1 , len = n ; if ( arr [ 0 ] == arr [ len - 1 ] ) { i = 2 ; len -- ; } for ( ; i < n ; i ++ ) if ( arr [ i ] == arr [ i - 1 ] ) i ++ ; else document . write ( arr [ i - 1 ] + " " ) ; if ( arr [ n - 1 ] != arr [ 0 ] && arr [ n - 1 ] != arr [ n - 2 ] ) document . write ( arr [ n - 1 ] ) ; } var arr = [ 7 , 7 , 8 , 8 , 9 , 1 , 1 , 4 , 2 , 2 ] ; var n = arr . length ; occurredOnce ( arr , n ) ;

Index/key variables: i
Accumulator variables: i, len
Javascript program:
function rvereseArray ( arr , start , end ) { while ( start < end ) { let temp = arr [ start ] ; arr [ start ] = arr [ end ] ; arr [ end ] = temp ; start ++ ; end -- ; } } function printArray ( arr , size ) { for ( let i = 0 ; i < size ; i ++ ) document . write ( arr [ i ] + " " ) ; } function splitArr ( arr , k , n ) { rvereseArray ( arr , 0 , n - 1 ) ; rvereseArray ( arr , 0 , n - k - 1 ) ; rvereseArray ( arr , n - k , n - 1 ) ; } let arr = new Array ( 12 , 10 , 5 , 6 , 52 , 36 ) ; let n = arr . length ; let k = 2 ; splitArr ( arr , k , n ) ; printArray ( arr , n ) ;

Index/key variables: end, i, start
Accumulator variables: end, i, start
Iterator variables: i
Javascript program:
function isRotation ( a , b ) { var n = a . length ; var m = b . length ; if ( n != m ) return false ; var lps = Array . from ( { length : n } , ( _ , i ) => 0 ) ; var len = 0 ; var i = 1 ; lps [ 0 ] = 0 ; while ( i < n ) { if ( a . charAt ( i ) == b . charAt ( len ) ) { lps [ i ] = ++ len ; ++ i ; } else { if ( len == 0 ) { lps [ i ] = 0 ; ++ i ; } else { len = lps [ len - 1 ] ; } } } i = 0 ; for ( k = lps [ n - 1 ] ; k < m ; ++ k ) { if ( b . charAt ( k ) != a . charAt ( i ++ ) ) return false ; } return true ; } var s1 = " " ; var s2 = " " ; document . write ( isRotation ( s1 , s2 ) ? " " : " " ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: k
Javascript program:
function countRotationsDivBy8 ( n ) { let len = n . length ; let count = 0 ; if ( len == 1 ) { let oneDigit = n [ 0 ] - ' ' ; if ( oneDigit % 8 == 0 ) return 1 ; return 0 ; } if ( len == 2 ) { let first = ( n [ 0 ] - ' ' ) * 10 + ( n [ 1 ] - ' ' ) ; let second = ( n [ 1 ] - ' ' ) * 10 + ( n [ 0 ] - ' ' ) ; if ( first % 8 == 0 ) count ++ ; if ( second % 8 == 0 ) count ++ ; return count ; } let threeDigit ; for ( let i = 0 ; i < ( len - 2 ) ; i ++ ) { threeDigit = ( n [ i ] - ' ' ) * 100 + ( n [ i + 1 ] - ' ' ) * 10 + ( n [ i + 2 ] - ' ' ) ; if ( threeDigit % 8 == 0 ) count ++ ; } threeDigit = ( n [ len - 1 ] - ' ' ) * 100 + ( n [ 0 ] - ' ' ) * 10 + ( n [ 1 ] - ' ' ) ; if ( threeDigit % 8 == 0 ) count ++ ; threeDigit = ( n [ len - 2 ] - ' ' ) * 100 + ( n [ len - 1 ] - ' ' ) * 10 + ( n [ 0 ] - ' ' ) ; if ( threeDigit % 8 == 0 ) count ++ ; return count ; } let n = " " ; document . write ( " " + countRotationsDivBy8 ( n ) ) ;

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Javascript program:
function minimunMoves ( arr , n ) { let ans = Number . MAX_VALUE ; for ( let i = 0 ; i < n ; i ++ ) { let curr_count = 0 ; let tmp = " " ; for ( let j = 0 ; j < n ; j ++ ) { tmp = arr [ j ] + arr [ j ] ; let index = tmp . indexOf ( arr [ i ] ) ; if ( index == arr [ i ] . length ) return - 1 ; curr_count += index ; } ans = Math . min ( curr_count , ans ) ; } return ans ; } let arr = [ " " , " " , " " , " " ] ; let n = arr . length ; document . write ( minimunMoves ( arr , n ) ) ;

Index/key variables: i, j
Accumulator variables: curr_count, i, j
Iterator variables: i, j
Javascript program:
class Node { constructor ( ) { this . data = 0 ; this . next = null ; } } function countRotation ( head ) { let count = 0 ; let min = head . data ; while ( head != null ) { if ( min > head . data ) break ; count ++ ; head = head . next ; } return count ; } function push ( head , data ) { let newNode = new Node ( ) ; newNode . data = data ; newNode . next = ( head ) ; ( head ) = newNode ; return head ; } function printList ( node ) { while ( node != null ) { document . write ( node . data + " " ) ; node = node . next ; } } let head = null ; head = push ( head , 12 ) ; head = push ( head , 11 ) ; head = push ( head , 8 ) ; head = push ( head , 5 ) ; head = push ( head , 18 ) ; head = push ( head , 15 ) ; printList ( head ) ; document . write ( " " ) ; document . write ( " " ) ; document . write ( countRotation ( head ) + " " ) ;

Accumulator variables: count
Class/struct names: Node
Javascript program:
class Node { constructor ( ) { this . data = 0 ; this . next = null ; } } var tail ; function rotateHelper ( blockHead , blockTail , d , k ) { if ( d == 0 ) return blockHead ; if ( d > 0 ) { var temp = blockHead ; for ( i = 1 ; temp . next . next != null && i < k - 1 ; i ++ ) temp = temp . next ; blockTail . next = blockHead ; tail = temp ; return rotateHelper ( blockTail , temp , d - 1 , k ) ; } if ( d < 0 ) { blockTail . next = blockHead ; tail = blockHead ; return rotateHelper ( blockHead . next , blockHead , d + 1 , k ) ; } return blockHead ; } function rotateByBlocks ( head , k , d ) { if ( head == null head . next == null ) return head ; if ( d == 0 ) return head ; var temp = head ; tail = null ; var i ; for ( i = 1 ; temp . next != null && i < k ; i ++ ) temp = temp . next ; var nextBlock = temp . next ; if ( i < k ) head = rotateHelper ( head , temp , d % k , i ) ; else head = rotateHelper ( head , temp , d % k , k ) ; tail . next = rotateByBlocks ( nextBlock , k , d % k ) ; return head ; } function push ( head_ref , new_data ) { var new_node = new Node ( ) ; new_node . data = new_data ; new_node . next = head_ref ; head_ref = new_node ; return head_ref ; } function printList ( node ) { while ( node != null ) { document . write ( node . data + " " ) ; node = node . next ; } } var head = null ; for ( i = 9 ; i > 0 ; i -= 1 ) head = push ( head , i ) ; document . write ( " " ) ; printList ( head ) ; var k = 3 , d = 2 ; head = rotateByBlocks ( head , k , d ) ; document . write ( " " ) ; printList ( head ) ;

Accumulator variables: i
Iterator variables: i
Class/struct names: Node
Javascript program:
function countRotations ( n ) { let len = n . length ; if ( len == 1 ) { let oneDigit = n [ 0 ] - ' ' ; if ( oneDigit % 4 == 0 ) return 1 ; return 0 ; } let twoDigit ; let count = 0 ; for ( let i = 0 ; i < ( len - 1 ) ; i ++ ) { twoDigit = ( n [ i ] - ' ' ) * 10 + ( n [ i + 1 ] - ' ' ) ; if ( twoDigit % 4 == 0 ) count ++ ; } twoDigit = ( n [ len - 1 ] - ' ' ) * 10 + ( n [ 0 ] - ' ' ) ; if ( twoDigit % 4 == 0 ) count ++ ; return count ; } let n = " " ; document . write ( " " + countRotations ( n ) ) ;

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Javascript program:
function minLexRotation ( str ) { let n = str . length ; let arr = new Array ( n ) ; let concat = str + str ; for ( let i = 0 ; i < n ; i ++ ) { arr [ i ] = concat . substring ( i , i + n ) ; } arr . sort ( ) ; return arr [ 0 ] ; } document . write ( minLexRotation ( " " ) + " " ) ; document . write ( minLexRotation ( " " ) + " " ) ; document . write ( minLexRotation ( " " ) + " " ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
let head ; class Node { constructor ( data ) { this . data = data ; this . next = null ; } } function print ( head ) { let temp = head ; while ( temp != null ) { document . write ( temp . data + " " ) ; temp = temp . next ; } } function NextGreaterElement ( head ) { let H = head ; let res = null ; let tempList = null ; do { let curr = head ; let Val = - 1 ; do { if ( head . data < curr . data ) { Val = curr . data ; break ; } curr = curr . next ; } while ( curr != head ) ; if ( res == null ) { res = new Node ( Val ) ; tempList = res ; } else { tempList . next = new Node ( Val ) ; tempList = tempList . next ; } head = head . next ; } while ( head != H ) ; print ( res ) ; } head = new Node ( 1 ) ; head . next = new Node ( 5 ) ; head . next . next = new Node ( 12 ) ; head . next . next . next = new Node ( 10 ) ; head . next . next . next . next = new Node ( 0 ) ; head . next . next . next . next . next = head ; NextGreaterElement ( head ) ;

Class/struct names: Node
Javascript program:
class Node { constructor ( ) { this . data = 0 ; this . next = null ; } }

Class/struct names: Node
Javascript program:
class Node { constructor ( ) { this . data = 0 ; this . next = null ; } } function printList ( n ) { while ( n != null ) { document . write ( n . data + " " ) ; n = n . next ; } } let head = null ; let second = null ; let third = null ; head = new Node ( ) ; second = new Node ( ) ; third = new Node ( ) ; head . data = 1 ; head . next = second ; second . data = 2 ; second . next = third ; third . data = 3 ; third . next = null ; printList ( head ) ;

Class/struct names: Node
Javascript program:
class Node { constructor ( val ) { this . data = val ; this . next = null ; } } function push ( head_ref , data ) { var ptr1 = new Node ( ) ; var temp = head_ref ; ptr1 . data = data ; ptr1 . next = head_ref ; if ( head_ref != null ) { while ( temp . next != head_ref ) temp = temp . next ; temp . next = ptr1 ; } else ptr1 . next = ptr1 ; head_ref = ptr1 ; return head_ref ; } function deleteNode ( head_ref , del ) { if ( head_ref == del ) head_ref = del . next ; var temp = head_ref ; while ( temp . next != del ) { temp = temp . next ; } temp . next = del . next ; return ; } function isEvenParity ( x ) { var parity = 0 ; while ( x != 0 ) { if ( ( x & 1 ) != 0 ) parity ++ ; x = x >> 1 ; } if ( parity % 2 == 0 ) return true ; else return false ; } function deleteEvenParityNodes ( head ) { if ( head == null ) return ; if ( head == head . next ) { if ( isEvenParity ( head . data ) ) head = null ; return ; } var ptr = head ; var next ; do { next = ptr . next ; if ( isEvenParity ( ptr . data ) ) deleteNode ( head , ptr ) ; ptr = next ; } while ( ptr != head ) ; if ( head == head . next ) { if ( isEvenParity ( head . data ) ) head = null ; return ; } } function printList ( head ) { if ( head == null ) { document . write ( " " ) ; return ; } var temp = head ; if ( head != null ) { do { document . write ( temp . data + " " ) ; temp = temp . next ; } while ( temp != head ) ; } } var head = null ; head = push ( head , 21 ) ; head = push ( head , 13 ) ; head = push ( head , 6 ) ; head = push ( head , 34 ) ; head = push ( head , 9 ) ; head = push ( head , 11 ) ; deleteEvenParityNodes ( head ) ; printList ( head ) ;

Accumulator variables: parity
Class/struct names: Node
Javascript program:
class Node { constructor ( ) { this . data = 0 ; this . next = null ; } } function push ( head_ref , data ) { var ptr1 = new Node ( ) ; var temp = head_ref ; ptr1 . data = data ; ptr1 . next = head_ref ; if ( head_ref != null ) { while ( temp . next != head_ref ) temp = temp . next ; temp . next = ptr1 ; } else ptr1 . next = ptr1 ; head_ref = ptr1 ; return head_ref ; } function deleteNode ( head_ref , del ) { var temp = head_ref ; if ( head_ref == del ) head_ref = del . next ; while ( temp . next != del ) { temp = temp . next ; } temp . next = del . next ; del = null ; return ; } function digitSum ( num ) { var sum = 0 ; while ( num > 0 ) { sum += ( num % 10 ) ; num = parseInt ( num / 10 ) ; } return sum ; } function deleteEvenDigitSumNodes ( head ) { var ptr = head ; var next ; do { if ( ! ( digitSum ( ptr . data ) % 2 == 1 ) ) deleteNode ( head , ptr ) ; next = ptr . next ; ptr = next ; } while ( ptr != head ) ; } function printList ( head ) { var temp = head ; if ( head != null ) { do { document . write ( temp . data + " " ) ; temp = temp . next ; } while ( temp != head ) ; } } var head = null ; head = push ( head , 21 ) ; head = push ( head , 13 ) ; head = push ( head , 6 ) ; head = push ( head , 34 ) ; head = push ( head , 11 ) ; head = push ( head , 9 ) ; deleteEvenDigitSumNodes ( head ) ; printList ( head ) ;

Accumulator variables: sum
Class/struct names: Node