dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
import java . io . * ; class GFG { private static void maxSumSubarr ( int A [ ] , int N , int K , int X ) { int sum_K = 0 ; for ( int i = 0 ; i < K ; i ++ ) { sum_K += A [ i ] ; } int Max_Sum = 0 ; if ( sum_K < X ) { Max_Sum = sum_K ; } for ( int i = K ; i < N ; i ++ ) { sum_K -= ( A [ i - K ] - A [ i ] ) ; if ( sum_K < X ) { Max_Sum = Math . max ( Max_Sum , sum_K ) ; } } System . out . println ( Max_Sum ) ; } public static void main ( String [ ] args ) { int arr [ ] = { - 5 , 8 , 7 , 2 , 10 , 1 , 20 , - 4 , 6 , 9 } ; int K = 5 ; int X = 30 ; int N = arr . length ; maxSumSubarr ( arr , N , K , X ) ; } }

Index/key variables: i
Accumulator variables: i, sum_K
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; import java . util . Arrays ; import java . util . Collections ; class GFG { static void rearrangeArray ( int a [ ] , int N ) { int sum = 0 ; for ( int i = 0 ; i < N ; i ++ ) { sum += a [ i ] ; } if ( sum == 0 ) { System . out . print ( " - 1" ) ; return ; } sum = 0 ; int b = 0 ; Arrays . sort ( a ) ; for ( int i = 0 ; i < N ; i ++ ) { sum += a [ i ] ; if ( sum == 0 ) { if ( a [ i ] != a [ N - 1 ] ) { sum -= a [ i ] ; int temp = a [ i ] ; a [ i ] = a [ N - 1 ] ; a [ N - 1 ] = temp ; sum += a [ i ] ; } else { b = 1 ; break ; } } } if ( b == 1 ) { b = 0 ; sum = 0 ; Arrays . sort ( a ) ; for ( int i = N - 1 ; i >= 0 ; i -- ) { sum += a [ i ] ; if ( sum == 0 ) { if ( a [ i ] != a [ 0 ] ) { sum -= a [ i ] ; int temp = a [ i ] ; a [ i ] = a [ 0 ] ; a [ 0 ] = temp ; sum += a [ i ] ; } else { b = 1 ; break ; } } } } if ( b == 1 ) { System . out . print ( " - 1" + " ▁ " ) ; return ; } for ( int i = 0 ; i < N ; i ++ ) { System . out . print ( a [ i ] + " ▁ " ) ; } } public static void main ( String args [ ] ) { int arr [ ] = { 1 , - 1 , 2 , 4 , 0 } ; int N = arr . length ; rearrangeArray ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void removeSmallestSubarray ( int arr [ ] , int n , int k ) { int [ ] mod_arr = new int [ n ] ; int total_sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { mod_arr [ i ] = ( arr [ i ] + k ) % k ; total_sum += arr [ i ] ; } int target_remainder = total_sum % k ; if ( target_remainder == 0 ) { System . out . print ( "0" ) ; return ; } HashMap < Integer , Integer > map1 = new HashMap < > ( ) ; map1 . put ( 0 , - 1 ) ; int curr_remainder = 0 ; int res = Integer . MAX_VALUE ; for ( int i = 0 ; i < n ; i ++ ) { curr_remainder = ( curr_remainder + arr [ i ] + k ) % k ; map1 . put ( curr_remainder , i ) ; int mod = ( curr_remainder - target_remainder + k ) % k ; if ( map1 . containsKey ( mod ) ) res = Math . min ( res , i - map1 . get ( mod ) ) ; } if ( res == Integer . MAX_VALUE res == n ) { res = - 1 ; } System . out . print ( res ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 3 , 1 , 4 , 2 } ; int N = arr . length ; int K = 6 ; removeSmallestSubarray ( arr , N , K ) ; } }

Index/key variables: i, n
Accumulator variables: i, total_sum
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static String toggleQuery ( char [ ] str , int Q [ ] [ ] , int M ) { int N = str . length ; int prefixCnt [ ] = new int [ N + 1 ] ; for ( int i = 0 ; i < M ; i ++ ) { prefixCnt [ Q [ i ] [ 0 ] ] += 1 ; prefixCnt [ Q [ i ] [ 1 ] + 1 ] -= 1 ; } for ( int i = 1 ; i <= N ; i ++ ) { prefixCnt [ i ] += prefixCnt [ i - 1 ] ; } for ( int i = 0 ; i < N ; i ++ ) { if ( prefixCnt [ i ] % 2 == 1 ) { str [ i ] = ( char ) ( '1' - str [ i ] + '0' ) ; } } return String . valueOf ( str ) ; } public static void main ( String [ ] args ) { String str = "101010" ; int Q [ ] [ ] = { { 0 , 1 } , { 2 , 5 } , { 2 , 3 } , { 1 , 4 } , { 0 , 5 } } ; int M = Q . length ; System . out . print ( toggleQuery ( str . toCharArray ( ) , Q , M ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static boolean isValid ( int wood [ ] , int N , int len , int K ) { int count = 0 ; for ( int i = 0 ; i < N ; i ++ ) { count += wood [ i ] / len ; } return count >= K ; } static int findMaxLen ( int wood [ ] , int N , int K ) { int left = 1 ; int right = Arrays . stream ( wood ) . max ( ) . getAsInt ( ) ; while ( left <= right ) { int mid = left + ( right - left ) / 2 ; if ( isValid ( wood , N , mid , K ) ) { left = mid + 1 ; } else { right = mid - 1 ; } } return right ; } public static void main ( String [ ] args ) { int wood [ ] = { 5 , 9 , 7 } ; int N = wood . length ; int K = 4 ; System . out . print ( findMaxLen ( wood , N , K ) ) ; } }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int countSum ( int a [ ] , int n , int sum ) { int i , j , k , l ; int count = 0 ; for ( i = 0 ; i < n - 3 ; i ++ ) { for ( j = i + 1 ; j < n - 2 ; j ++ ) { for ( k = j + 1 ; k < n - 1 ; k ++ ) { for ( l = k + 1 ; l < n ; l ++ ) { if ( a [ i ] + a [ j ] + a [ k ] + a [ l ] == sum ) count ++ ; } } } } return count ; } public static void main ( String args [ ] ) { int arr [ ] = { 4 , 5 , 3 , 1 , 2 , 4 } ; int S = 13 ; int N = arr . length ; System . out . print ( countSum ( arr , N , S ) ) ; } }

Index/key variables: i, j, k, l
Accumulator variables: count, i, j, k, l
Iterator variables: i, j, k, l
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int minSwaps ( String S , int n ) { int swaps = 0 ; @ SuppressWarnings ( " unchecked " ) Vector < Integer > [ ] arr = new Vector [ 26 ] ; for ( int i = 0 ; i < arr . length ; i ++ ) arr [ i ] = new Vector < Integer > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { int pos = S . charAt ( i ) - ' a ' ; arr [ pos ] . add ( i ) ; } for ( char ch = ' a ' ; ch <= ' z ' ; ++ ch ) { int pos = ch - ' a ' ; for ( int i = 1 ; i < arr [ pos ] . size ( ) ; ++ i ) { swaps += Math . abs ( arr [ pos ] . get ( i ) - arr [ pos ] . get ( i - 1 ) - 1 ) ; } } return swaps ; } public static void main ( String [ ] args ) { String S = " abbccabbcc " ; int N = S . length ( ) ; System . out . print ( minSwaps ( S , N ) ) ; } }

Index/key variables: i, pos
Accumulator variables: i, swaps
Iterator variables: ch, i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static class pair { int first , second ; public pair ( int first , int second ) { this . first = first ; this . second = second ; } } static void printConnections ( Vector < pair > store , Vector < Integer > ind , int ind1 ) { for ( pair pr : store ) { System . out . print ( pr . first + " ▁ " + pr . second + "NEW_LINE"); } if ( ind . size ( ) != 0 ) { for ( int x : ind ) { System . out . print ( ind1 + " ▁ " + ( x + 1 ) + "NEW_LINE"); } } } static void constructGraph ( char arr [ ] , int N ) { Vector < Integer > ind = new Vector < > ( ) ; Vector < pair > store = new Vector < > ( ) ; char x = arr [ 0 ] ; int count = 0 ; int ind1 = - 1 ; for ( int i = 1 ; i <= N - 1 ; ++ i ) { if ( arr [ i ] != x ) { ind1 = i + 1 ; count ++ ; store . add ( new pair ( 1 , i + 1 ) ) ; } else { ind . add ( i ) ; } } if ( count == 0 ) { System . out . print ( " Not ▁ Possible " ) ; } else { System . out . print ( " Possible " + "NEW_LINE"); printConnections ( store , ind , ind1 ) ; } } public static void main ( String [ ] args ) { int N = 5 ; char arr [ ] = { ' a ' , ' b ' , ' a ' , ' b ' , ' c ' } ; constructGraph ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: count
Iterator variables: i, pr, x
Class/struct names: GFG, pair
Java program:
import java . util . * ; class GFG { static void findMinimumOperations ( char [ ] a , char [ ] b ) { int step = 0 ; int last_index = 0 ; while ( ! Arrays . equals ( a , b ) ) { for ( int i = 0 ; i < a . length ; i ++ ) { if ( a [ i ] != b [ i ] ) { last_index = i ; } } for ( int i = 0 ; i <= last_index ; i ++ ) { a [ i ] = ( a [ i ] == '0' ) ? '1' : '0' ; } step ++ ; } System . out . print ( step ) ; } public static void main ( String [ ] args ) { String A = "101010" , B = "110011" ; findMinimumOperations ( A . toCharArray ( ) , B . toCharArray ( ) ) ; } }

Index/key variables: i
Accumulator variables: i, step
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int isValid ( int arr [ ] , int n , int m , int d ) { for ( int i = 0 ; i < m ; i ++ ) { if ( Math . abs ( arr [ n - m + i ] - arr [ i ] ) < d ) { return 0 ; } } return 1 ; } static void countPairs ( int arr [ ] , int N , int K ) { int ans = 0 ; int left = 0 , right = N / 2 + 1 ; Arrays . sort ( arr ) ; while ( left < right ) { int mid = ( left + right ) / 2 ; if ( isValid ( arr , N , mid , K ) == 1 ) { ans = mid ; left = mid + 1 ; } else right = mid - 1 ; } System . out . print ( ans ) ; } public static void main ( String args [ ] ) { int arr [ ] = { 1 , 3 , 3 , 5 } ; int K = 2 ; int N = arr . length ; countPairs ( arr , N , K ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void max_distance ( int a [ ] , int temp [ ] , int n ) { Map < Integer , Integer > mp = new HashMap < Integer , Integer > ( ) ; for ( int i = 1 ; i <= n ; i ++ ) { temp [ i ] = - 1 ; } for ( int i = 0 ; i < n ; i ++ ) { if ( mp . get ( a [ i ] ) == null ) temp [ a [ i ] ] = i + 1 ; else temp [ a [ i ] ] = Math . max ( temp [ a [ i ] ] , i - mp . getOrDefault ( a [ i ] , 0 ) ) ; mp . put ( a [ i ] , i ) ; } for ( int i = 1 ; i <= n ; i ++ ) { if ( temp [ i ] != - 1 ) temp [ i ] = Math . max ( temp [ i ] , n - mp . getOrDefault ( i , 0 ) ) ; } } static void min_comm_ele ( int a [ ] , int ans [ ] , int temp [ ] , int n ) { max_distance ( a , temp , n ) ; for ( int i = 1 ; i <= n ; i ++ ) { ans [ i ] = - 1 ; } for ( int i = 1 ; i <= n ; i ++ ) { if ( temp [ i ] >= 0 && ans [ temp [ i ] ] == - 1 ) ans [ temp [ i ] ] = i ; } for ( int i = 1 ; i <= n ; i ++ ) { if ( i > 1 && ans [ i - 1 ] != - 1 ) { if ( ans [ i ] == - 1 ) ans [ i ] = ans [ i - 1 ] ; else ans [ i ] = Math . min ( ans [ i ] , ans [ i - 1 ] ) ; } System . out . print ( ans [ i ] + " ▁ " ) ; } } public static void main ( String args [ ] ) { int N = 6 ; int a [ ] = { 1 , 3 , 4 , 5 , 6 , 7 } ; int [ ] temp = new int [ 100 ] ; Arrays . fill ( temp , 0 ) ; int [ ] ans = new int [ 100 ] ; Arrays . fill ( ans , 0 ) ; min_comm_ele ( a , ans , temp , N ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void FindTrip ( int arr [ ] , int N ) { for ( int i = 1 ; i < N - 1 ; i ++ ) { int p = arr [ i - 1 ] ; int q = arr [ i ] ; int r = arr [ i + 1 ] ; if ( p < q && q > r ) { System . out . println ( ( i - 1 ) + " ▁ " + ( i ) + " ▁ " + ( i + 1 ) ) ; return ; } } System . out . println ( - 1 ) ; } public static void main ( String args [ ] ) { int arr [ ] = { 2 , 1 , 4 , 3 } ; int N = arr . length ; FindTrip ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int cntSubarrays ( int arr [ ] , int N ) { int cntSub = 0 ; int cntUnique = 0 ; Map < Integer , Integer > cntFreq = new HashMap < Integer , Integer > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = i ; j < N ; j ++ ) { cntFreq . put ( arr [ j ] , cntFreq . getOrDefault ( arr [ j ] , 0 ) + 1 ) ; if ( cntFreq . get ( arr [ j ] ) == 1 ) { cntUnique ++ ; } else if ( cntFreq . get ( arr [ j ] ) == 2 ) { cntUnique -- ; } if ( cntUnique == 0 ) { cntSub ++ ; } } cntFreq . clear ( ) ; cntUnique = 0 ; } return cntSub ; } public static void main ( String args [ ] ) { int arr [ ] = { 1 , 1 , 2 , 2 , 2 } ; int N = arr . length ; System . out . println ( cntSubarrays ( arr , N ) ) ; } }

Index/key variables: j
Accumulator variables: cntSub, cntUnique, i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { public static boolean checkPalinK ( String str , int K ) { int N = str . length ( ) ; int cntFreq [ ] = new int [ 256 ] ; for ( int i = 0 ; i < N ; i ++ ) { cntFreq [ str . charAt ( i ) ] ++ ; } int cntOddFreq = 0 ; for ( int i = 0 ; i < 256 ; i ++ ) { if ( cntFreq [ i ] % 2 == 1 ) { cntOddFreq ++ ; } } if ( cntOddFreq <= ( K + 1 ) ) { return true ; } return false ; } public static void main ( String args [ ] ) { String str = " geeksforgeeks " ; int K = 2 ; if ( checkPalinK ( str , K ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } }

Index/key variables: i
Accumulator variables: cntOddFreq, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { static void countRemovableElem ( int [ ] arr , int N ) { int [ ] hash = new int [ N + 1 ] ; Arrays . fill ( hash , 0 ) ; int mex = N + 1 ; for ( int i = 0 ; i < N ; i ++ ) { if ( arr [ i ] <= N ) hash [ arr [ i ] ] = 1 ; } for ( int i = 1 ; i <= N ; i ++ ) { if ( hash [ i ] == 0 ) { mex = i ; break ; } } System . out . println ( N - ( mex - 1 ) ) ; } public static void main ( String [ ] args ) { int [ ] arr = { 2 , 3 , 5 , 1 , 6 } ; int N = arr . length ; countRemovableElem ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void printIndexes ( char [ ] str ) { int N = str . length ; int [ ] cntFreq = new int [ 256 ] ; for ( int i = 0 ; i < N ; i ++ ) { cntFreq [ str [ i ] ] ++ ; } int [ ] cntLeftFreq = new int [ 256 ] ; for ( int i = 0 ; i < N ; i ++ ) { int cntLeft = 0 ; int cntRight = 0 ; for ( int j = str [ i ] - 1 ; j >= 0 ; j -- ) { cntLeft += cntLeftFreq [ j ] ; cntRight += cntFreq [ j ] - cntLeftFreq [ j ] ; } cntLeftFreq [ str [ i ] ] ++ ; if ( cntLeft == cntRight && cntLeft != 0 ) { System . out . print ( i + " ▁ " ) ; } } } public static void main ( String [ ] args ) { String str = " aabacdabbb " ; printIndexes ( str . toCharArray ( ) ) ; } }

Index/key variables: i, j
Accumulator variables: cntLeft, cntRight, i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . Arrays ; class GFG { static int Count_Number ( int x ) { int ans = 0 ; if ( x % 99 != 0 ) { ans = - 1 ; } else { int diff = x / 99 ; for ( int i = 1 ; i < 10 ; i ++ ) { for ( int j = 1 ; j < 10 ; j ++ ) { if ( ( i - j ) == diff ) { ans += 10 ; } } } } return ans ; } public static void main ( String [ ] args ) { int x = 792 ; System . out . println ( Count_Number ( x ) ) ; } }

Accumulator variables: ans, i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int INF = Integer . MAX_VALUE ; static int [ ] findMaxPoint ( int arr [ ] [ ] , int i , int n ) { if ( i == n ) return new int [ ] { INF , INF } ; boolean flag = true ; for ( int j = 0 ; j < n ; j ++ ) { if ( j == i ) continue ; if ( arr [ j ] [ 0 ] >= arr [ i ] [ 0 ] arr [ j ] [ 1 ] >= arr [ i ] [ 1 ] ) { flag = false ; break ; } } if ( flag ) return arr [ i ] ; return findMaxPoint ( arr , i + 1 , n ) ; } static void findMaxPoints ( int arr [ ] [ ] , int n ) { int ans [ ] = findMaxPoint ( arr , 0 , n ) ; if ( ans [ 0 ] == INF ) { System . out . println ( - 1 ) ; } else { System . out . println ( " ( " + ans [ 0 ] + " ▁ " + ans [ 1 ] + " ) " ) ; } } public static void main ( String [ ] args ) { int arr [ ] [ ] = new int [ ] [ ] { { 1 , 2 } , { 2 , 1 } , { 3 , 4 } , { 4 , 3 } , { 5 , 5 } } ; int N = arr . length ; findMaxPoints ( arr , N ) ; } }

Index/key variables: i, j
Accumulator variables: j
Iterator variables: j
Boolean variables: flag
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static void findMaxPoint ( int arr [ ] [ ] ) { int maxX = Integer . MIN_VALUE ; int maxY = Integer . MIN_VALUE ; int n = arr . length ; for ( int i = 0 ; i < n ; i ++ ) { maxX = Math . max ( maxX , arr [ i ] [ 0 ] ) ; maxY = Math . max ( maxY , arr [ i ] [ 1 ] ) ; } for ( int i = 0 ; i < n ; i ++ ) { if ( maxX == arr [ i ] [ 0 ] && maxY == arr [ i ] [ 1 ] ) { System . out . println ( " ( " + maxX + " , ▁ " + maxY + " ) " ) ; return ; } } System . out . println ( - 1 ) ; } public static void main ( String [ ] args ) { int arr [ ] [ ] = new int [ ] [ ] { { 1 , 2 } , { 2 , 1 } , { 3 , 4 } , { 4 , 3 } , { 5 , 5 } } ; findMaxPoint ( arr ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int find_index ( int [ ] arr , int n , int K ) { for ( int i = 0 ; i < n ; i ++ ) if ( arr [ i ] == K ) return i ; else if ( arr [ i ] > K ) return i ; return n ; } public static void main ( String [ ] args ) { int [ ] arr = { 1 , 3 , 5 , 6 } ; int n = arr . length ; int K = 2 ; System . out . println ( find_index ( arr , n , K ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void minSubarray ( int [ ] arr , int N ) { HashMap < Integer , Integer > mp = new HashMap < Integer , Integer > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { int mini = Integer . MAX_VALUE ; for ( int j = i ; j < N ; j ++ ) { mini = Math . min ( mini , arr [ j ] ) ; if ( mp . containsKey ( mini ) ) { mp . put ( mini , mp . get ( mini ) + 1 ) ; } else { mp . put ( mini , 1 ) ; } } } for ( int i = 0 ; i < N ; i ++ ) { System . out . print ( mp . get ( arr [ i ] ) + " ▁ " ) ; } } public static void main ( String [ ] args ) { int arr [ ] = { 3 , 2 , 1 , 4 } ; int N = arr . length ; minSubarray ( arr , N ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static class pair { int first , second ; public pair ( int first , int second ) { this . first = first ; this . second = second ; } } static void minSubarray ( int [ ] arr , int N ) { int [ ] result = new int [ N ] ; Stack < pair > l = new Stack < > ( ) ; Stack < pair > r = new Stack < > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { int count = 1 ; while ( ! l . isEmpty ( ) && l . peek ( ) . first > arr [ i ] ) { count += l . peek ( ) . second ; l . pop ( ) ; } l . add ( new pair ( arr [ i ] , count ) ) ; result [ i ] = count ; } for ( int i = N - 1 ; i >= 0 ; i -- ) { int count = 1 ; while ( ! r . isEmpty ( ) && r . peek ( ) . first >= arr [ i ] ) { count += r . peek ( ) . second ; r . pop ( ) ; } r . add ( new pair ( arr [ i ] , count ) ) ; result [ i ] *= count ; } for ( int i = 0 ; i < N ; i ++ ) { System . out . print ( result [ i ] + " ▁ " ) ; } } public static void main ( String [ ] args ) { int arr [ ] = { 3 , 2 , 1 , 4 } ; int N = arr . length ; minSubarray ( arr , N ) ; } }

Index/key variables: N, i
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG, pair
Java program:
import java . io . * ; import java . util . * ; class GFG { static boolean isPrime ( int num ) { if ( num <= 1 ) return false ; for ( int i = 2 ; i * i <= num ; i ++ ) if ( num % i == 0 ) return false ; return true ; } static boolean isFulPrime ( int n ) { if ( ! isPrime ( n ) ) return false ; else { while ( n > 0 ) { int rem = n % 10 ; if ( ! ( rem == 2 rem == 3 rem == 5 rem == 7 ) ) return false ; n = n / 10 ; } } return true ; } static int countFulPrime ( int L , int R ) { int cnt = 0 ; for ( int i = L ; i <= R ; i ++ ) { if ( ( i % 2 ) != 0 && isFulPrime ( i ) ) { cnt ++ ; } } return cnt ; } public static void main ( String [ ] args ) { int L = 1 , R = 100 ; int ans = 0 ; if ( L < 3 ) ans ++ ; System . out . println ( ans + countFulPrime ( L , R ) ) ; } }

Accumulator variables: ans, cnt, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static void printAlter ( int [ ] arr , int N ) { for ( int currIndex = 0 ; currIndex < N ; currIndex ++ ) { if ( currIndex % 2 == 0 ) { System . out . print ( arr [ currIndex ] + " ▁ " ) ; } } } public static void main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 3 , 4 , 5 } ; int N = arr . length ; printAlter ( arr , N ) ; } }

Index/key variables: currIndex
Accumulator variables: currIndex
Iterator variables: currIndex
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int findmin ( String s ) { int n = s . length ( ) ; int i , j , maximum = 0 ; int [ ] incr = new int [ n + 1 ] ; for ( i = 0 ; i < n ; i ++ ) { incr [ i + 1 ] = incr [ i ] ; if ( s . charAt ( i ) == '0' ) { incr [ i + 1 ] ++ ; } } for ( i = 0 ; i < n ; i ++ ) { for ( j = i + 1 ; j < n ; j ++ ) { maximum = Math . max ( maximum , incr [ i ] + j - i + 1 - ( incr [ j + 1 ] - incr [ i ] ) + incr [ n ] - incr [ j + 1 ] ) ; } } return n - maximum ; } public static void main ( String [ ] args ) { String S = "0110100110" ; int minimum = findmin ( S ) ; System . out . println ( minimum ) ; } }

Index/key variables: i, n
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { public static boolean isPower ( int x ) { if ( x != 0 && ( x & ( x - 1 ) ) == 0 ) return true ; return false ; } public static void maximumlength ( int arr [ ] , int N ) { int max_length = 0 ; int max_len_subarray = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( isPower ( arr [ i ] ) ) { max_length ++ ; max_len_subarray = Math . max ( max_length , max_len_subarray ) ; } else { max_length = 0 ; } } System . out . println ( max_len_subarray ) ; } public static void main ( String args [ ] ) { int arr [ ] = { 2 , 5 , 4 , 6 , 8 , 8 , 2 } ; int N = arr . length ; maximumlength ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: i, max_length
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int findLengthOfShortestSubarray ( int arr [ ] , int N ) { int minlength = Integer . MAX_VALUE ; int left = 0 ; int right = N - 1 ; while ( left < right && arr [ left + 1 ] >= arr [ left ] ) { left ++ ; } if ( left == N - 1 ) return 0 ; while ( right > left && arr [ right - 1 ] <= arr [ right ] ) { right -- ; } minlength = Math . min ( N - left - 1 , right ) ; int j = right ; for ( int i = 0 ; i < left + 1 ; i ++ ) { if ( arr [ i ] <= arr [ j ] ) { minlength = Math . min ( minlength , j - i - 1 ) ; } else if ( j < N - 1 ) { j ++ ; } else { break ; } } return minlength ; } public static void main ( String [ ] args ) { int arr [ ] = { 6 , 3 , 10 , 11 , 15 , 20 , 13 , 3 , 18 , 12 } ; int N = arr . length ; System . out . print ( ( findLengthOfShortestSubarray ( arr , N ) ) ) ; } }

Index/key variables: i, j, left, right
Accumulator variables: i, j, left, right
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void minSub ( int N ) { int count = 0 ; while ( N >= 0 ) { int num = N ; int rev = 0 ; while ( num != 0 ) { int digit = num % 10 ; rev = ( rev * 10 ) + digit ; num = num / 10 ; } if ( N == rev ) { break ; } count ++ ; N -- ; } System . out . print ( count ) ; } public static void main ( String [ ] args ) { int N = 3456 ; minSub ( N ) ; } }

Accumulator variables: N, count
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int numberOfGP ( int L [ ] , int N ) { if ( N <= 2 ) return 0 ; int count = 0 ; int res = 0 ; for ( int i = 2 ; i < N ; ++ i ) { if ( L [ i - 1 ] * L [ i - 1 ] == L [ i ] * L [ i - 2 ] ) { ++ count ; } else { count = 0 ; } res += count ; } return res ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 4 , 8 , 16 , 24 } ; int N = arr . length ; System . out . print ( numberOfGP ( arr , N ) ) ; } }

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