dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
import java . util . * ; class GFG { static void matrix ( int n , int m , int [ ] [ ] li ) { int ctr = 0 ; while ( ctr < 2 * n - 1 ) { for ( int i = 0 ; i < Math . abs ( n - ctr - 1 ) ; i ++ ) { System . out . print ( " ▁ " ) ; } Vector < Integer > lst = new Vector < Integer > ( ) ; for ( int i = 0 ; i < m ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { if ( i + j == ctr ) { lst . add ( li [ i ] [ j ] ) ; } } } for ( int i = lst . size ( ) - 1 ; i >= 0 ; i -- ) { System . out . print ( lst . get ( i ) + " ▁ " ) ; } System . out . println ( ) ; ctr += 1 ; } } public static void main ( String [ ] args ) { int n = 8 ; int m = n ; int [ ] [ ] li = { { 4 , 5 , 6 , 9 , 8 , 7 , 1 , 4 } , { 1 , 5 , 9 , 7 , 5 , 3 , 1 , 6 } , { 7 , 5 , 3 , 1 , 5 , 9 , 8 , 0 } , { 6 , 5 , 4 , 7 , 8 , 9 , 3 , 7 } , { 3 , 5 , 6 , 4 , 8 , 9 , 2 , 1 } , { 3 , 1 , 6 , 4 , 7 , 9 , 5 , 0 } , { 8 , 0 , 7 , 2 , 3 , 1 , 0 , 8 } , { 7 , 5 , 3 , 1 , 5 , 9 , 8 , 5 } } ; matrix ( n , m , li ) ; } }

Index/key variables: i, j
Accumulator variables: ctr, i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
class GFG { static int getFirstElement ( int a [ ] , int N , int K , int M ) { K %= N ; int index ; if ( K >= M ) index = ( N - K ) + ( M - 1 ) ; else index = ( M - K - 1 ) ; int result = a [ index ] ; return result ; } public static void main ( String [ ] args ) { int a [ ] = { 1 , 2 , 3 , 4 , 5 } ; int N = 5 ; int K = 3 , M = 2 ; System . out . println ( getFirstElement ( a , N , K , M ) ) ; } }

Index/key variables: index
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { public static int getFirstElement ( int [ ] a , int N , int K , int M ) { K %= N ; int index = ( K + M - 1 ) % N ; int result = a [ index ] ; return result ; } public static void main ( String [ ] args ) { int a [ ] = { 3 , 4 , 5 , 23 } ; int N = a . length ; int K = 2 , M = 1 ; System . out . println ( getFirstElement ( a , N , K , M ) ) ; } }

Index/key variables: index
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; import java . lang . * ; class GFG { static void left_rotate ( int [ ] arr ) { int last = arr [ 1 ] ; for ( int i = 3 ; i < arr . length ; i = i + 2 ) { arr [ i - 2 ] = arr [ i ] ; } arr [ arr . length - 1 ] = last ; } static void right_rotate ( int [ ] arr ) { int start = arr [ arr . length - 2 ] ; for ( int i = arr . length - 4 ; i >= 0 ; i = i - 2 ) { arr [ i + 2 ] = arr [ i ] ; } arr [ 0 ] = start ; } public static void rotate ( int arr [ ] ) { left_rotate ( arr ) ; right_rotate ( arr ) ; for ( int i = 0 ; i < arr . length ; i ++ ) { System . out . print ( arr [ i ] + " ▁ " ) ; } } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 3 , 4 , 5 , 6 } ; rotate ( arr ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int maximumMatchingPairs ( int perm1 [ ] , int perm2 [ ] , int n ) { int [ ] left = new int [ n ] ; int [ ] right = new int [ n ] ; HashMap < Integer , Integer > mp1 = new HashMap < > ( ) ; HashMap < Integer , Integer > mp2 = new HashMap < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { mp1 . put ( perm1 [ i ] , i ) ; } for ( int j = 0 ; j < n ; j ++ ) { mp2 . put ( perm2 [ j ] , j ) ; } for ( int i = 0 ; i < n ; i ++ ) { int idx2 = mp2 . get ( perm1 [ i ] ) ; int idx1 = i ; if ( idx1 == idx2 ) { left [ i ] = 0 ; right [ i ] = 0 ; } else if ( idx1 < idx2 ) { left [ i ] = ( n - ( idx2 - idx1 ) ) ; right [ i ] = ( idx2 - idx1 ) ; } else { left [ i ] = ( idx1 - idx2 ) ; right [ i ] = ( n - ( idx1 - idx2 ) ) ; } } HashMap < Integer , Integer > freq1 = new HashMap < > ( ) ; HashMap < Integer , Integer > freq2 = new HashMap < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( freq1 . containsKey ( left [ i ] ) ) freq1 . put ( left [ i ] , freq1 . get ( left [ i ] ) + 1 ) ; else freq1 . put ( left [ i ] , 1 ) ; if ( freq2 . containsKey ( right [ i ] ) ) freq2 . put ( right [ i ] , freq2 . get ( right [ i ] ) + 1 ) ; else freq2 . put ( right [ i ] , 1 ) ; } int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { ans = Math . max ( ans , Math . max ( freq1 . get ( left [ i ] ) , freq2 . get ( right [ i ] ) ) ) ; } return ans ; } public static void main ( String [ ] args ) { int P1 [ ] = { 5 , 4 , 3 , 2 , 1 } ; int P2 [ ] = { 1 , 2 , 3 , 4 , 5 } ; int n = P1 . length ; System . out . print ( maximumMatchingPairs ( P1 , P2 , n ) ) ; } }

Index/key variables: i, j, n
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
public class GFG { public static int countRotation ( int [ ] arr , int n ) { for ( int i = 1 ; i < n ; i ++ ) { if ( arr [ i ] < arr [ i - 1 ] ) { return i ; } } return 0 ; } public static void main ( String [ ] args ) { int [ ] arr1 = { 4 , 5 , 1 , 2 , 3 } ; System . out . println ( countRotation ( arr1 , arr1 . length ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
public class GFG { public static int countRotation ( int [ ] arr , int low , int high ) { if ( low > high ) { return 0 ; } int mid = low + ( high - low ) / 2 ; if ( mid < high && arr [ mid ] > arr [ mid + 1 ] ) { return mid + 1 ; } if ( mid > low && arr [ mid ] < arr [ mid - 1 ] ) { return mid ; } if ( arr [ mid ] > arr [ low ] ) { return countRotation ( arr , mid + 1 , high ) ; } if ( arr [ mid ] < arr [ high ] ) { return countRotation ( arr , low , mid - 1 ) ; } else { int rightIndex = countRotation ( arr , mid + 1 , high ) ; int leftIndex = countRotation ( arr , low , mid - 1 ) ; if ( rightIndex == 0 ) { return leftIndex ; } return rightIndex ; } } public static void main ( String [ ] args ) { int [ ] arr1 = { 4 , 5 , 1 , 2 , 3 } ; System . out . println ( countRotation ( arr1 , 0 , arr1 . length - 1 ) ) ; } }

Index/key variables: high, low, mid
Class/struct names: GFG
Java program:
import java . util . ArrayList ; import java . util . Arrays ; import java . util . HashSet ; import java . util . LinkedList ; import java . util . Queue ; class GFG { static int minCircularRotations ( String target , ArrayList < String > blocked , int N ) { String start = " " ; for ( int i = 0 ; i < N ; i ++ ) { start += '0' ; } HashSet < String > avoid = new HashSet < > ( ) ; for ( int i = 0 ; i < blocked . size ( ) ; i ++ ) avoid . add ( blocked . get ( i ) ) ; if ( avoid . contains ( start ) ) return - 1 ; if ( avoid . contains ( target ) ) return - 1 ; Queue < String > qu = new LinkedList < > ( ) ; qu . add ( start ) ; int count = 0 ; while ( ! qu . isEmpty ( ) ) { count ++ ; int size = qu . size ( ) ; for ( int j = 0 ; j < size ; j ++ ) { StringBuilder st = new StringBuilder ( qu . poll ( ) ) ; for ( int i = 0 ; i < N ; i ++ ) { char ch = st . charAt ( i ) ; st . setCharAt ( i , ( char ) ( st . charAt ( i ) + 1 ) ) ; if ( st . charAt ( i ) > '9' ) st . setCharAt ( i , '0' ) ; if ( st . toString ( ) . equals ( target ) ) return count ; if ( ! avoid . contains ( st . toString ( ) ) ) qu . add ( st . toString ( ) ) ; avoid . add ( st . toString ( ) ) ; st . setCharAt ( i , ( char ) ( ch - 1 ) ) ; if ( st . charAt ( i ) < '0' ) st . setCharAt ( i , '9' ) ; if ( st . toString ( ) . equals ( target ) ) return count ; if ( ! avoid . contains ( st . toString ( ) ) ) qu . add ( st . toString ( ) ) ; avoid . add ( st . toString ( ) ) ; st . setCharAt ( i , ch ) ; } } } return - 1 ; } public static void main ( String [ ] args ) { int N = 4 ; String target = "7531" ; ArrayList < String > blocked = new ArrayList < > ( Arrays . asList ( "1543" , "7434" , "7300" , "7321" , "2427" ) ) ; System . out . println ( minCircularRotations ( target , blocked , N ) ) ; } }

Accumulator variables: count, i, j, start
Iterator variables: i, j
Class/struct names: GFG
Java program:
class GFG { static void rotatedSumQuery ( int arr [ ] , int n , int [ ] [ ] query , int Q ) { int [ ] prefix = new int [ 2 * n ] ; for ( int i = 0 ; i < n ; i ++ ) { prefix [ i ] = arr [ i ] ; prefix [ i + n ] = arr [ i ] ; } for ( int i = 1 ; i < 2 * n ; i ++ ) prefix [ i ] += prefix [ i - 1 ] ; int start = 0 ; for ( int q = 0 ; q < Q ; q ++ ) { if ( query [ q ] [ 0 ] == 1 ) { int k = query [ q ] [ 1 ] ; start = ( start + k ) % n ; } else if ( query [ q ] [ 0 ] == 2 ) { int L , R ; L = query [ q ] [ 1 ] ; R = query [ q ] [ 2 ] ; if ( start + L == 0 ) System . out . print ( prefix [ start + R ] + "NEW_LINE"); else System . out . print ( prefix [ start + R ] - prefix [ start + L - 1 ] + "NEW_LINE"); } } } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 3 , 4 , 5 , 6 } ; int Q = 5 ; int [ ] [ ] query = { { 2 , 1 , 3 } , { 1 , 3 } , { 2 , 0 , 3 } , { 1 , 4 } , { 2 , 3 , 5 } } ; int n = arr . length ; rotatedSumQuery ( arr , n , query , Q ) ; } }

Index/key variables: i, q
Accumulator variables: i, q
Iterator variables: i, q
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { static void isConversionPossible ( String s1 , String s2 , int x ) { int diff = 0 , n ; n = s1 . length ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( s1 . charAt ( i ) == s2 . charAt ( i ) ) continue ; diff = ( ( int ) ( s2 . charAt ( i ) - s1 . charAt ( i ) ) + 26 ) % 26 ; if ( diff > x ) { System . out . println ( " NO " ) ; return ; } } System . out . println ( " YES " ) ; } public static void main ( String [ ] args ) { String s1 = " you " ; String s2 = " ara " ; int x = 6 ; isConversionPossible ( s1 , s2 , x ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int countRotation ( int n ) { int count = 0 ; do { int digit = n % 10 ; if ( digit == 0 ) count ++ ; n = n / 10 ; } while ( n != 0 ) ; return count ; } public static void main ( String [ ] args ) { int n = 10203 ; System . out . println ( countRotation ( n ) ) ; } }

Accumulator variables: count
Class/struct names: GFG
Java program:
class GFG { static class Node { int data ; Node next ; } static Node push ( Node head_ref , int new_data ) { Node new_node = new Node ( ) ; new_node . data = new_data ; new_node . next = ( head_ref ) ; ( head_ref ) = new_node ; return head_ref ; } static void printList ( Node node ) { while ( node != null ) { System . out . print ( node . data + " ▁ - > ▁ " ) ; node = node . next ; } System . out . print ( " null " ) ; } static Node rightRotate ( Node head , int k ) { if ( head == null ) return head ; Node tmp = head ; int len = 1 ; while ( tmp . next != null ) { tmp = tmp . next ; len ++ ; } if ( k > len ) k = k % len ; k = len - k ; if ( k == 0 k == len ) return head ; Node current = head ; int cnt = 1 ; while ( cnt < k && current != null ) { current = current . next ; cnt ++ ; } if ( current == null ) return head ; Node kthnode = current ; tmp . next = head ; head = kthnode . next ; kthnode . next = null ; return head ; } public static void main ( String args [ ] ) { Node head = null ; head = push ( head , 5 ) ; head = push ( head , 4 ) ; head = push ( head , 3 ) ; head = push ( head , 2 ) ; head = push ( head , 1 ) ; int k = 2 ; Node updated_head = rightRotate ( head , k ) ; printList ( updated_head ) ; } }

Accumulator variables: cnt, len
Class/struct names: GFG, Node
Java program:
class GFG { static boolean isPossible ( int a [ ] , int n ) { if ( n <= 2 ) return true ; int flag = 0 ; for ( int 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 ( int 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 ; int val1 = Integer . MAX_VALUE , mini = - 1 , val2 = Integer . MIN_VALUE , maxi = 0 ; for ( int 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 ( int i = 0 ; i < maxi ; i ++ ) { if ( a [ i ] > a [ i + 1 ] ) { flag = 0 ; break ; } } if ( flag == 1 && maxi + 1 == mini ) { flag = 1 ; for ( int i = mini ; i < n - 1 ; i ++ ) { if ( a [ i ] > a [ i + 1 ] ) { flag = 0 ; break ; } } if ( flag == 1 ) return true ; } flag = 1 ; for ( int i = 0 ; i < mini ; i ++ ) { if ( a [ i ] < a [ i + 1 ] ) { flag = 0 ; break ; } } if ( flag == 1 && maxi - 1 == mini ) { flag = 1 ; for ( int i = maxi ; i < n - 1 ; i ++ ) { if ( a [ i ] < a [ i + 1 ] ) { flag = 0 ; break ; } } if ( flag == 1 ) return true ; } return false ; } public static void main ( String args [ ] ) { int a [ ] = { 4 , 5 , 6 , 2 , 3 } ; int n = a . length ; if ( isPossible ( a , n ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int cntRotations ( String s , int n ) { String str = s + s ; int pre [ ] = new int [ 2 * n ] ; for ( int i = 0 ; i < 2 * n ; i ++ ) { if ( i != 0 ) pre [ i ] += pre [ i - 1 ] ; if ( str . charAt ( i ) == ' a ' || str . charAt ( i ) == ' e ' || str . charAt ( i ) == ' i ' || str . charAt ( i ) == ' o ' || str . charAt ( i ) == ' u ' ) { pre [ i ] ++ ; } } int ans = 0 ; for ( int i = n - 1 ; i < 2 * n - 1 ; i ++ ) { int r = i , l = i - n ; int x1 = pre [ r ] ; if ( l >= 0 ) x1 -= pre [ l ] ; r = i - n / 2 ; int left = pre [ r ] ; if ( l >= 0 ) left -= pre [ l ] ; int right = x1 - left ; if ( left > right ) { ans ++ ; } } return ans ; } public static void main ( String args [ ] ) { String s = " abecidft " ; int n = s . length ( ) ; System . out . println ( cntRotations ( s , n ) ) ; } }

Index/key variables: i, l, r
Accumulator variables: ans, i, left, x1
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { public static int cntRotations ( char s [ ] , int n ) { int lh = 0 , rh = 0 , i , ans = 0 ; for ( i = 0 ; i < n / 2 ; ++ i ) if ( s [ i ] == ' a ' s [ i ] == ' e ' s [ i ] == ' i ' s [ i ] == ' o ' s [ i ] == ' u ' ) { lh ++ ; } for ( i = n / 2 ; i < n ; ++ i ) if ( s [ i ] == ' a ' s [ i ] == ' e ' s [ i ] == ' i ' s [ i ] == ' o ' s [ i ] == ' u ' ) { rh ++ ; } if ( lh > rh ) ans ++ ; for ( i = 1 ; i < n ; ++ i ) { if ( s [ i - 1 ] == ' a ' s [ i - 1 ] == ' e ' s [ i - 1 ] == ' i ' s [ i - 1 ] == ' o ' s [ i - 1 ] == ' u ' ) { rh ++ ; lh -- ; } if ( s [ ( i - 1 + n / 2 ) % n ] == ' a ' || s [ ( i - 1 + n / 2 ) % n ] == ' e ' || s [ ( i - 1 + n / 2 ) % n ] == ' i ' || s [ ( i - 1 + n / 2 ) % n ] == ' o ' || s [ ( i - 1 + n / 2 ) % n ] == ' u ' ) { rh -- ; lh ++ ; } if ( lh > rh ) ans ++ ; } return ans ; } public static void main ( String [ ] args ) { char s [ ] = { ' a ' , ' b ' , ' e ' , ' c ' , ' i ' , ' d ' , ' f ' , ' t ' } ; int n = s . length ; System . out . println ( cntRotations ( s , n ) ) ; } }

Index/key variables: i
Accumulator variables: ans, lh, rh
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int size = 2 ; static void performQueries ( String str , int n , int queries [ ] [ ] , int q ) { int ptr = 0 ; for ( int i = 0 ; i < q ; i ++ ) { if ( queries [ i ] [ 0 ] == 1 ) { ptr = ( ptr + queries [ i ] [ 1 ] ) % n ; } else { int k = queries [ i ] [ 1 ] ; int index = ( ptr + k - 1 ) % n ; System . out . println ( str . charAt ( index ) ) ; } } } public static void main ( String [ ] args ) { String str = " abcdefgh " ; int n = str . length ( ) ; int queries [ ] [ ] = { { 1 , 2 } , { 2 , 2 } , { 1 , 4 } , { 2 , 7 } } ; int q = queries . length ; performQueries ( str , n , queries , q ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class Solution { static void countOddRotations ( int n ) { int odd_count = 0 , even_count = 0 ; do { int digit = n % 10 ; if ( digit % 2 == 1 ) odd_count ++ ; else even_count ++ ; n = n / 10 ; } while ( n != 0 ) ; System . out . println ( " Odd ▁ = ▁ " + odd_count ) ; System . out . println ( " Even ▁ = ▁ " + even_count ) ; } public static void main ( String [ ] args ) { int n = 1234 ; countOddRotations ( n ) ; } }

Accumulator variables: even_count, odd_count
Class/struct names: Solution
Java program:
class GFG { static int numberOfDigits ( int n ) { int cnt = 0 ; while ( n > 0 ) { cnt ++ ; n /= 10 ; } return cnt ; } static void cal ( int num ) { int digits = numberOfDigits ( num ) ; int powTen = ( int ) Math . pow ( 10 , digits - 1 ) ; for ( int i = 0 ; i < digits - 1 ; i ++ ) { int firstDigit = num / powTen ; int left = ( ( num * 10 ) + firstDigit ) - ( firstDigit * powTen * 10 ) ; System . out . print ( left + " ▁ " ) ; num = left ; } } public static void main ( String [ ] args ) { int num = 1445 ; cal ( num ) ; } }

Accumulator variables: cnt, i, n
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static void CheckKCycles ( int n , String s ) { boolean ff = true ; int x = 0 ; for ( int i = 1 ; i < n ; i ++ ) { x = ( s . substring ( i ) + s . substring ( 0 , i ) ) . length ( ) ; if ( x >= s . length ( ) ) { continue ; } ff = false ; break ; } if ( ff ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } public static void main ( String [ ] args ) { int n = 3 ; String s = "123" ; CheckKCycles ( n , s ) ; } }

Accumulator variables: i
Iterator variables: i
Boolean variables: ff
Class/struct names: GFG
Java program:
import java . util . * ; class Solution { static class ListNode { int data ; ListNode next ; } static void rotateSubList ( ListNode A , int m , int n , int k ) { int size = n - m + 1 ; if ( k > size ) { k = k % size ; } if ( k == 0 k == size ) { ListNode head = A ; while ( head != null ) { System . out . print ( head . data ) ; head = head . next ; } return ; } ListNode link = null ; if ( m == 1 ) { link = A ; } ListNode c = A ; int count = 0 ; ListNode end = null ; ListNode 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 ) { ListNode d = c . next ; c . next = link ; end . next = d ; ListNode head = A ; while ( head != null ) { System . out . print ( head . data + " ▁ " ) ; head = head . next ; } return ; } c = c . next ; } } static ListNode push ( ListNode head , int val ) { ListNode new_node = new ListNode ( ) ; new_node . data = val ; new_node . next = ( head ) ; ( head ) = new_node ; return head ; } public static void main ( String args [ ] ) { ListNode 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 ) ; ListNode tmp = head ; System . out . print ( " Given ▁ List : ▁ " ) ; while ( tmp != null ) { System . out . print ( tmp . data + " ▁ " ) ; tmp = tmp . next ; } System . out . println ( ) ; int m = 3 , n = 6 , k = 2 ; System . out . print ( " After ▁ rotation ▁ of ▁ sublist : ▁ " ) ; rotateSubList ( head , m , n , k ) ; } }

Accumulator variables: count
Class/struct names: ListNode, Solution
Java program:
public class GFG { static boolean rightRotationDivisor ( int N ) { int lastDigit = N % 10 ; int rightRotation = ( int ) ( lastDigit * Math . pow ( 10 , ( int ) ( Math . log10 ( N ) ) ) + Math . floor ( N / 10 ) ) ; return ( rightRotation % N == 0 ) ; } static void generateNumbers ( int m ) { for ( int i = ( int ) Math . pow ( 10 , ( m - 1 ) ) ; i < Math . pow ( 10 , m ) ; i ++ ) if ( rightRotationDivisor ( i ) ) System . out . println ( i ) ; } public static void main ( String args [ ] ) { int m = 3 ; generateNumbers ( m ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; import java . io . * ; class GFG { static void generateNumbers ( int m ) { ArrayList < Integer > numbers = new ArrayList < > ( ) ; int k_max , x ; for ( int y = 0 ; y < 10 ; y ++ ) { k_max = ( int ) ( Math . pow ( 10 , m - 2 ) * ( 10 * y + 1 ) ) / ( int ) ( Math . pow ( 10 , m - 1 ) + y ) ; for ( int k = 1 ; k <= k_max ; k ++ ) { x = ( int ) ( y * ( Math . pow ( 10 , m - 1 ) - k ) ) / ( 10 * k - 1 ) ; if ( ( int ) ( y * ( Math . pow ( 10 , m - 1 ) - k ) ) % ( 10 * k - 1 ) == 0 ) numbers . add ( 10 * x + y ) ; } } Collections . sort ( numbers ) ; for ( int i = 0 ; i < numbers . size ( ) ; i ++ ) System . out . println ( numbers . get ( i ) ) ; } public static void main ( String args [ ] ) { int m = 3 ; generateNumbers ( m ) ; } }

Accumulator variables: i, k, y
Iterator variables: i, k, y
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static void checkIfSortRotated ( int arr [ ] , int n ) { int minEle = Integer . MAX_VALUE ; int maxEle = Integer . MIN_VALUE ; int minIndex = - 1 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] < minEle ) { minEle = arr [ i ] ; minIndex = i ; } } boolean flag1 = true ; for ( int i = 1 ; i < minIndex ; i ++ ) { if ( arr [ i ] < arr [ i - 1 ] ) { flag1 = false ; break ; } } boolean flag2 = true ; for ( int i = minIndex + 1 ; i < n ; i ++ ) { if ( arr [ i ] < arr [ i - 1 ] ) { flag2 = false ; break ; } } if ( minIndex == 0 ) { System . out . print ( " NO " ) ; return ; } if ( flag1 && flag2 && ( arr [ n - 1 ] < arr [ 0 ] ) ) System . out . println ( " YES " ) ; else System . out . print ( " NO " ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 3 , 4 , 5 , 1 , 2 } ; int n = arr . length ; checkIfSortRotated ( arr , n ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Boolean variables: flag1, flag2
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static boolean checkIfSortRotated ( int arr [ ] , int n ) { int x = 0 , y = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( arr [ i ] < arr [ i + 1 ] ) x ++ ; else y ++ ; } if ( x == 1 y == 1 ) { if ( arr [ n - 1 ] < arr [ 0 ] ) x ++ ; else y ++ ; if ( x == 1 y == 1 ) return true ; } return false ; } public static void main ( String [ ] args ) { int arr [ ] = { 5 , 1 , 2 , 3 , 4 } ; int n = arr . length ; boolean x = checkIfSortRotated ( arr , n ) ; if ( x == true ) System . out . println ( " YES " ) ; else System . out . println ( " NO " ) ; } }

Index/key variables: i
Accumulator variables: i, x, y
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int N = 4 ; static void rotate90Clockwise ( int arr [ ] [ ] ) { for ( int j = 0 ; j < N ; j ++ ) { for ( int i = N - 1 ; i >= 0 ; i -- ) System . out . print ( arr [ i ] [ j ] + " ▁ " ) ; System . out . println ( ) ; } } public static void main ( String [ ] args ) { int 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
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static void rotate ( int [ ] [ ] arr ) { int n = arr . length ; for ( int i = 0 ; i < n ; ++ i ) { for ( int j = 0 ; j < i ; ++ j ) { int temp = arr [ i ] [ j ] ; arr [ i ] [ j ] = arr [ j ] [ i ] ; arr [ j ] [ i ] = temp ; } } for ( int i = 0 ; i < n ; ++ i ) { for ( int j = 0 ; j < n / 2 ; ++ j ) { int temp = arr [ i ] [ j ] ; arr [ i ] [ j ] = arr [ i ] [ n - j - 1 ] ; arr [ i ] [ n - j - 1 ] = temp ; } } } static void printMatrix ( int arr [ ] [ ] ) { int n = arr . length ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) System . out . print ( arr [ i ] [ j ] + " ▁ " ) ; System . out . println ( ) ; } } public static void main ( String [ ] args ) { int arr [ ] [ ] = { { 1 , 2 , 3 , 4 } , { 5 , 6 , 7 , 8 } , { 9 , 10 , 11 , 12 } , { 13 , 14 , 15 , 16 } } ; rotate ( arr ) ; printMatrix ( arr ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG