dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
import java . util . * ; class GFG { static Vector < Integer > v = new Vector < Integer > ( ) ; static int bin ( int val , int k , int n ) { int lo = 0 ; int hi = n ; int mid ; int ans = - 1 ; while ( lo <= hi ) { mid = lo + ( hi - lo ) / 2 ; if ( v . get ( mid ) - val <= k ) { lo = mid + 1 ; ans = mid ; } else hi = mid - 1 ; } return ans ; } static void findSubarraySumK ( int arr [ ] , int N , int K ) { int sum = 0 ; v . add ( 0 ) ; for ( int i = 0 ; i < N ; i ++ ) { sum += arr [ i ] ; v . add ( sum ) ; } int l = 0 , ans = 0 , r ; for ( int i = 0 ; i < v . size ( ) ; i ++ ) { r = bin ( v . get ( i ) , K , N ) ; ans = Math . max ( ans , r - i ) ; } System . out . print ( ans ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 6 , 8 , 14 , 9 , 4 , 11 , 10 } ; int N = arr . length ; int K = 13 ; findSubarraySumK ( arr , N , K ) ; } }

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int splitArray ( int arr [ ] , int N ) { Arrays . sort ( arr ) ; int result = Integer . MAX_VALUE ; for ( int i = 1 ; i < N ; i ++ ) { result = Math . min ( result , arr [ i ] - arr [ i - 1 ] ) ; } return result ; } public static void main ( String [ ] args ) { int arr [ ] = { 3 , 1 , 2 , 6 , 4 } ; int N = arr . length ; System . out . print ( splitArray ( arr , N ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int findValue ( int R , int C ) { int k = ( R * ( R - 1 ) ) / 2 + 1 ; int diff = R + 1 ; for ( int i = 1 ; i < C ; i ++ ) { k = ( k + diff ) ; diff ++ ; } return k ; } public static void main ( String [ ] args ) { int R = 4 ; int C = 4 ; int k = findValue ( R , C ) ; System . out . println ( k ) ; } }

Accumulator variables: diff, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void makeGroups ( int a [ ] , int n ) { int [ ] v = new int [ n + 1 ] ; for ( int i = 0 ; i < n ; i ++ ) { v [ a [ i ] ] ++ ; } int no_of_groups = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { no_of_groups += v [ i ] / i ; v [ i ] = v [ i ] % i ; } int i = 1 ; int total = 0 ; for ( i = 1 ; i <= n ; i ++ ) { if ( v [ i ] != 0 ) { total = v [ i ] ; break ; } } i ++ ; while ( i <= n ) { if ( v [ i ] != 0 ) { total += v [ i ] ; if ( total >= i ) { int rem = total - i ; no_of_groups ++ ; total = rem ; } } i ++ ; } System . out . print ( no_of_groups + "NEW_LINE"); } public static void main ( String [ ] args ) { int arr [ ] = { 2 , 3 , 1 , 2 , 2 } ; int size = arr . length ; makeGroups ( arr , size ) ; } }

Index/key variables: i
Accumulator variables: i, no_of_groups, total
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static final int N = 3 ; static final int M = 4 ; static int FindColumn ( int mat [ ] [ ] ) { int row = 0 , col = M - 1 ; int flag = 0 ; while ( row < N && col >= 0 ) { if ( mat [ row ] [ col ] == 1 ) { col -- ; flag = 1 ; } else { row ++ ; } } col ++ ; if ( flag != 0 ) return col + 1 ; else return - 1 ; } public static void main ( String [ ] args ) { int [ ] [ ] mat = { { 0 , 0 , 0 , 1 } , { 0 , 1 , 1 , 1 } , { 0 , 0 , 1 , 1 } } ; System . out . print ( FindColumn ( mat ) ) ; } }

Index/key variables: col, row
Accumulator variables: col, row
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void findNumbers ( int N , int M ) { int m = M ; Map < Integer , Integer > remLen = new HashMap < > ( ) ; int len , remainder = 0 ; for ( len = 1 ; len <= N + 1 ; ++ len ) { remainder = M % N ; if ( ! remLen . containsKey ( remainder ) ) { remLen . put ( remainder , len ) ; } else { break ; } M = M * 10 + m ; M = M % N ; } int LenA = len ; int LenB = remLen . getOrDefault ( remainder , 0 ) ; for ( int i = 0 ; i < LenB ; ++ i ) System . out . print ( m ) ; System . out . print ( " ▁ " ) ; for ( int i = 0 ; i < LenA ; ++ i ) System . out . print ( m ) ; } public static void main ( String [ ] args ) { int N = 8 , M = 2 ; findNumbers ( N , M ) ; } }

Iterator variables: i, len
Class/struct names: GFG
Java program:
class GFG { static int [ ] [ ] prefix_2D = new int [ 2005 ] [ 2005 ] ; static int subMatrixSum ( int i , int j , int len ) { return prefix_2D [ i ] [ j ] - prefix_2D [ i ] [ j - len ] - prefix_2D [ i - len ] [ j ] + prefix_2D [ i - len ] [ j - len ] ; } static int numberOfWays ( int a [ ] , int b [ ] , int n , int m , int k ) { for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = 1 ; j <= m ; j ++ ) { if ( a [ i - 1 ] == b [ j - 1 ] ) prefix_2D [ i ] [ j ] = 1 ; else prefix_2D [ i ] [ j ] = 0 ; } } for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = 1 ; j <= m ; j ++ ) { prefix_2D [ i ] [ j ] += prefix_2D [ i ] [ j - 1 ] ; } } for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = 1 ; j <= m ; j ++ ) { prefix_2D [ i ] [ j ] += prefix_2D [ i - 1 ] [ j ] ; } } int answer = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = 1 ; j <= m ; j ++ ) { int low = 1 ; int high = Math . min ( i , j ) ; while ( low < high ) { int mid = ( low + high ) >> 1 ; if ( subMatrixSum ( i , j , mid ) >= k ) { high = mid ; } else { low = mid + 1 ; } } if ( subMatrixSum ( i , j , low ) >= k ) { answer += ( Math . min ( i , j ) - low + 1 ) ; } } } return answer ; } public static void main ( String [ ] args ) { int N = 2 , M = 3 ; int A [ ] = { 1 , 2 } ; int B [ ] = { 1 , 2 , 3 } ; int K = 1 ; System . out . print ( numberOfWays ( A , B , N , M , K ) ) ; } }

Index/key variables: i, j
Accumulator variables: answer, i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static String findSmallest ( char [ ] s ) { int len = s . length ; int [ ] loccur = new int [ 26 ] ; Arrays . fill ( loccur , - 1 ) ; for ( int i = len - 1 ; i >= 0 ; -- i ) { int chI = s [ i ] - ' a ' ; if ( loccur [ chI ] == - 1 ) { loccur [ chI ] = i ; } } char [ ] sorted_s = s ; Arrays . sort ( sorted_s ) ; for ( int i = 0 ; i < len ; ++ i ) { if ( s [ i ] != sorted_s [ i ] ) { int chI = sorted_s [ i ] - ' a ' ; int last_occ = loccur [ chI ] ; char temp = s [ last_occ ] ; s [ last_occ ] = s [ i ] ; s [ i ] = temp ; break ; } } return String . valueOf ( s ) ; } public static void main ( String [ ] args ) { String s = " geeks " ; System . out . print ( findSmallest ( s . toCharArray ( ) ) ) ; } }

Index/key variables: chI, i, last_occ
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static final int N = 4 ; static final int M = 5 ; static void preProcess ( int [ ] [ ] mat , int [ ] [ ] aux ) { for ( int i = 0 ; i < M ; i ++ ) aux [ 0 ] [ i ] = mat [ 0 ] [ i ] ; for ( int i = 1 ; i < N ; i ++ ) for ( int j = 0 ; j < M ; j ++ ) aux [ i ] [ j ] = mat [ i ] [ j ] + aux [ i - 1 ] [ j ] ; for ( int i = 0 ; i < N ; i ++ ) for ( int j = 1 ; j < M ; j ++ ) aux [ i ] [ j ] += aux [ i ] [ j - 1 ] ; } static int sumQuery ( int [ ] [ ] aux , int tli , int tlj , int rbi , int rbj ) { int res = aux [ rbi ] [ rbj ] ; if ( tli > 0 ) res = res - aux [ tli - 1 ] [ rbj ] ; if ( tlj > 0 ) res = res - aux [ rbi ] [ tlj - 1 ] ; if ( tli > 0 && tlj > 0 ) res = res + aux [ tli - 1 ] [ tlj - 1 ] ; return res ; } static boolean check ( int mid , int [ ] [ ] aux , int K ) { boolean satisfies = true ; for ( int x = 0 ; x < N ; x ++ ) { for ( int y = 0 ; y < M ; y ++ ) { if ( x + mid - 1 <= N - 1 && y + mid - 1 <= M - 1 ) { if ( sumQuery ( aux , x , y , x + mid - 1 , y + mid - 1 ) > K ) satisfies = false ; } } } return ( satisfies == true ) ; } static int maximumSquareSize ( int [ ] [ ] mat , int K ) { int [ ] [ ] aux = new int [ N ] [ M ] ; preProcess ( mat , aux ) ; int low = 1 , high = Math . min ( N , M ) ; int mid ; while ( high - low > 1 ) { mid = ( low + high ) / 2 ; if ( check ( mid , aux , K ) ) { low = mid ; } else high = mid ; } if ( check ( high , aux , K ) ) return high ; return low ; } public static void main ( String [ ] args ) { int K = 30 ; int [ ] [ ] mat = { { 1 , 2 , 3 , 4 , 6 } , { 5 , 3 , 8 , 1 , 2 } , { 4 , 6 , 7 , 5 , 5 } , { 2 , 4 , 8 , 9 , 4 } } ; System . out . print ( maximumSquareSize ( mat , K ) ) ; } }

Index/key variables: M, N, i, j, rbi, rbj
Accumulator variables: i, j, x, y
Iterator variables: i, j, x, y
Boolean variables: satisfies
Class/struct names: GFG
Java program:
class GFG { static int segment_tree [ ] = new int [ 4 * 1000000 ] ; static int build ( int A [ ] , int start , int end , int node ) { if ( start == end ) segment_tree [ node ] = A [ start ] ; else { int mid = ( start + end ) / 2 ; segment_tree [ node ] = Math . max ( build ( A , start , mid , 2 * node + 1 ) , build ( A , mid + 1 , end , 2 * node + 2 ) ) ; } return segment_tree [ node ] ; } static int query ( int start , int end , int l , int r , int node ) { if ( start > r end < l ) return - 1 ; if ( start >= l && end <= r ) return segment_tree [ node ] ; int mid = ( start + end ) / 2 ; return Math . max ( query ( start , mid , l , r , 2 * node + 1 ) , query ( mid + 1 , end , l , r , 2 * node + 2 ) ) ; } static int longestSubArray ( int A [ ] , int N , int K ) { int res = 1 ; int preSum [ ] = new int [ N + 1 ] ; preSum [ 0 ] = A [ 0 ] ; for ( int i = 0 ; i < N ; i ++ ) preSum [ i + 1 ] = preSum [ i ] + A [ i ] ; build ( A , 0 , N - 1 , 0 ) ; for ( int i = 0 ; i < N ; i ++ ) { int start = i , end = N - 1 , mid , max_index = i ; while ( start <= end ) { mid = ( start + end ) / 2 ; int max_element = query ( 0 , N - 1 , i , mid , 0 ) ; int expected_sum = ( mid - i + 1 ) * max_element ; int actual_sum = preSum [ mid + 1 ] - preSum [ i ] ; if ( expected_sum - actual_sum <= K ) { start = mid + 1 ; max_index = Math . max ( max_index , mid ) ; } else { end = mid - 1 ; } } res = Math . max ( res , max_index - i + 1 ) ; } return res ; } public static void main ( String [ ] args ) { int arr [ ] = { 2 , 0 , 4 , 6 , 7 } , K = 6 ; int N = arr . length ; System . out . println ( longestSubArray ( arr , N , K ) ) ; } }

Index/key variables: i, node, start
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int countNums ( int l , int r ) { int cnt = 0 ; for ( int i = l ; i <= r ; i ++ ) { int lastDigit = ( i % 10 ) ; if ( ( lastDigit % 10 ) == 2 || ( lastDigit % 10 ) == 3 || ( lastDigit % 10 ) == 9 ) { cnt ++ ; } } return cnt ; } public static void main ( String [ ] args ) { int l = 11 , r = 33 ; System . out . print ( countNums ( l , r ) ) ; } }

Accumulator variables: cnt, i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int findMinimumK ( int a [ ] , int n , int s ) { int maximum = a [ 0 ] ; for ( int i = 0 ; i < n ; i ++ ) { maximum = Math . max ( maximum , a [ i ] ) ; } int low = 1 , high = maximum + 1 ; int ans = high ; while ( low <= high ) { int mid = ( low + high ) / 2 ; int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { sum += ( int ) ( a [ i ] / mid ) ; } if ( sum > s ) low = mid + 1 ; else { ans = Math . min ( ans , mid ) ; high = mid - 1 ; } } return ans ; } public static void main ( String [ ] args ) { int a [ ] = { 10 , 7 , 8 , 10 , 12 , 19 } ; int n = a . length ; int s = 27 ; System . out . println ( findMinimumK ( a , n , s ) ) ; } }

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int [ ] [ ] SparseTable = new int [ 100001 ] [ 51 ] ; static void buildSparseTable ( int a [ ] , int n ) { for ( int i = 0 ; i < n ; i ++ ) { SparseTable [ i ] [ 0 ] = a [ i ] ; } for ( int j = 1 ; j <= 19 ; j ++ ) { for ( int i = 0 ; i <= n - ( 1 << j ) ; i ++ ) { SparseTable [ i ] [ j ] = __gcd ( SparseTable [ i ] [ j - 1 ] , SparseTable [ i + ( 1 << ( j - 1 ) ) ] [ j - 1 ] ) ; } } } static int queryForGCD ( int L , int R ) { int returnValue ; int j = ( int ) ( Math . log ( R - L + 1 ) ) ; returnValue = __gcd ( SparseTable [ L ] [ j ] , SparseTable [ R - ( 1 << j ) + 1 ] [ j ] ) ; return returnValue ; } static int nextPosition ( int tempGCD , int startPointer , int prevEndPointer , int n ) { int high = n - 1 ; int low = prevEndPointer ; int mid = prevEndPointer ; int nextPos = prevEndPointer ; while ( high >= low ) { mid = ( ( high + low ) >> 1 ) ; if ( queryForGCD ( startPointer , mid ) == tempGCD ) { nextPos = mid ; low = mid + 1 ; } else { high = mid - 1 ; } } return nextPos + 1 ; } static int calculateSum ( int a [ ] , int n ) { buildSparseTable ( a , n ) ; int endPointer , startPointer , prevEndPointer , tempGCD ; int tempAns = 0 ; for ( int i = 0 ; i < n ; i ++ ) { endPointer = i ; startPointer = i ; prevEndPointer = i ; tempGCD = a [ i ] ; while ( endPointer < n ) { endPointer = nextPosition ( tempGCD , startPointer , prevEndPointer , n ) ; tempAns += ( ( endPointer - prevEndPointer ) * tempGCD ) ; prevEndPointer = endPointer ; if ( endPointer < n ) { tempGCD = __gcd ( tempGCD , a [ endPointer ] ) ; } } } return tempAns ; } static int __gcd ( int a , int b ) { return b == 0 ? a : __gcd ( b , a % b ) ; } public static void main ( String [ ] args ) { int n = 6 ; int a [ ] = { 2 , 2 , 2 , 3 , 5 , 5 } ; System . out . println ( calculateSum ( a , n ) ) ; } }

Index/key variables: L, endPointer, i, j
Accumulator variables: i, j, tempAns
Iterator variables: i, j
Class/struct names: GFG
Java program:
class GFG { static int partition ( int arr [ ] , int low , int high ) { int temp ; int pivot = arr [ high ] ; int i = ( low - 1 ) ; for ( int j = low ; j <= high - 1 ; j ++ ) { if ( arr [ j ] <= pivot ) { i ++ ; temp = arr [ i ] ; arr [ i ] = arr [ j ] ; arr [ j ] = temp ; } } temp = arr [ i + 1 ] ; arr [ i + 1 ] = arr [ high ] ; arr [ high ] = temp ; return ( i + 1 ) ; } static int kthSmallest ( int a [ ] , int left , int right , int k ) { while ( left <= right ) { int pivotIndex = partition ( a , left , right ) ; if ( pivotIndex == k - 1 ) return a [ pivotIndex ] ; else if ( pivotIndex > k - 1 ) right = pivotIndex - 1 ; else left = pivotIndex + 1 ; } return - 1 ; } public static void main ( String [ ] args ) { int arr [ ] = { 10 , 4 , 5 , 8 , 11 , 6 , 26 } ; int n = arr . length ; int k = 5 ; System . out . println ( " K - th ▁ smallest ▁ element ▁ is ▁ " + kthSmallest ( arr , 0 , n - 1 , k ) ) ; } }

Index/key variables: high, i, j, pivotIndex
Accumulator variables: i, j
Iterator variables: j
Class/struct names: GFG
Java program:
import java . util . Arrays ; class GFG { static void Max_Sum ( int arr [ ] , int n , int k ) { int p = n ; Arrays . sort ( arr ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] >= k ) { p = i ; break ; } } int maxsum = 0 , a = 0 , b = 0 ; for ( int i = 0 ; i < p ; i ++ ) { for ( int j = i + 1 ; j < p ; j ++ ) { if ( arr [ i ] + arr [ j ] < k && arr [ i ] + arr [ j ] > maxsum ) { maxsum = arr [ i ] + arr [ j ] ; a = arr [ i ] ; b = arr [ j ] ; } } } System . out . print ( a + " ▁ " + b ) ; } public static void main ( String [ ] args ) { int [ ] arr = { 5 , 20 , 110 , 100 , 10 } ; int k = 85 ; int n = arr . length ; Max_Sum ( arr , n , k ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
class GFG { static boolean isPalindrome ( String str , int i , int j ) { while ( i < j ) { if ( str . charAt ( i ) != str . charAt ( j ) ) { return false ; } i ++ ; j -- ; } return true ; } static int maxLenPalindrome ( String str , int n , char ch ) { int maxLen = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( str . charAt ( i ) == ch ) { for ( int j = n - 1 ; j >= i ; j -- ) { if ( str . charAt ( j ) == ch ) { if ( isPalindrome ( str , i , j ) ) { maxLen = Math . max ( maxLen , j - i + 1 ) ; break ; } } } } } return maxLen ; } public static void main ( String [ ] args ) { String str = " lapqooqpqpl " ; int n = str . length ( ) ; char ch = ' p ' ; System . out . println ( maxLenPalindrome ( str , n , ch ) ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int MAX = 26 ; static String countingsort ( char [ ] s ) { int [ ] count = new int [ MAX ] ; for ( int i = 0 ; i < s . length ; i ++ ) { count [ s [ i ] - ' a ' ] ++ ; } int index = 0 ; for ( int i = 0 ; i < MAX ; i ++ ) { int j = 0 ; while ( j < count [ i ] ) { s [ index ++ ] = ( char ) ( i + ' a ' ) ; j ++ ; } } return String . valueOf ( s ) ; } static boolean isPossible ( Vector < String > v , String str ) { str = countingsort ( str . toCharArray ( ) ) ; for ( int i = 0 ; i < v . size ( ) - 1 ; i ++ ) { for ( int j = i + 1 ; j < v . size ( ) ; j ++ ) { String temp = v . get ( i ) + v . get ( j ) ; temp = countingsort ( temp . toCharArray ( ) ) ; if ( temp . equals ( str ) ) { return true ; } } } return false ; } public static void main ( String [ ] args ) { String str = " amazon " ; String [ ] arr = { " fds " , " oxq " , " zoa " , " epw " , " amn " } ; Vector < String > v = new Vector < String > ( Arrays . asList ( arr ) ) ; if ( isPossible ( v , str ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } }

Index/key variables: MAX, i
Accumulator variables: i, index, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
public class GFG { static final int MAX = 256 ; static int freq [ ] [ ] ; static void preCalculate ( String str , int n ) { freq [ ( int ) str . charAt ( 0 ) ] [ 0 ] = 1 ; for ( int i = 1 ; i < n ; i ++ ) { char ch = str . charAt ( i ) ; for ( int j = 0 ; j < MAX ; j ++ ) { char charToUpdate = ( char ) j ; if ( charToUpdate == ch ) freq [ j ] [ i ] = freq [ j ] [ i - 1 ] + 1 ; else freq [ j ] [ i ] = freq [ j ] [ i - 1 ] ; } } } static int getFrequency ( char ch , int l , int r ) { if ( l == 0 ) return freq [ ( int ) ch ] [ r ] ; else return ( freq [ ( int ) ch ] [ r ] - freq [ ( int ) ch ] [ l - 1 ] ) ; } static String firstNonRepeating ( String str , int n , int l , int r ) { for ( int i = l ; i < r ; i ++ ) { char ch = str . charAt ( i ) ; if ( getFrequency ( ch , l , r ) == 1 ) return ( " " + ch ) ; } return " - 1" ; } public static void main ( String [ ] args ) { String str = " GeeksForGeeks " ; int n = str . length ( ) ; int queries [ ] [ ] = { { 0 , 3 } , { 2 , 3 } , { 5 , 12 } } ; int q = queries . length ; freq = new int [ MAX ] [ n ] ; preCalculate ( str , n ) ; for ( int i = 0 ; i < q ; i ++ ) { System . out . println ( firstNonRepeating ( str , n , queries [ i ] [ 0 ] , queries [ i ] [ 1 ] ) ) ; } } }

Index/key variables: MAX, i, j, n, r
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int maxLength ( String s , int n ) { int ans = Integer . MIN_VALUE ; Vector < Integer > A = new Vector < Integer > ( ) ; Vector < Integer > L = new Vector < Integer > ( ) ; Vector < Integer > R = new Vector < Integer > ( ) ; int [ ] freq = new int [ n + 5 ] ; for ( int i = 0 ; i < 26 ; i ++ ) { int count = 0 ; for ( int j = 0 ; j < n ; j ++ ) { if ( s . charAt ( j ) - ' a ' == i ) count ++ ; freq [ j ] = count ; } for ( int j = 1 ; j < n ; j ++ ) { L . add ( ( 2 * freq [ j - 1 ] ) - j ) ; R . add ( ( 2 * freq [ j ] ) - j ) ; } int max_len = Integer . MIN_VALUE ; int min_val = Integer . MAX_VALUE ; for ( int j = 0 ; j < L . size ( ) ; j ++ ) { min_val = Math . min ( min_val , L . get ( j ) ) ; A . add ( min_val ) ; int l = 0 , r = j ; while ( l <= r ) { int mid = ( l + r ) >> 1 ; if ( A . get ( mid ) <= R . get ( j ) ) { max_len = Math . max ( max_len , j - mid + 1 ) ; r = mid - 1 ; } else { l = mid + 1 ; } } } ans = Math . max ( ans , max_len ) ; A . clear ( ) ; R . clear ( ) ; L . clear ( ) ; } return ans ; } public static void main ( String [ ] args ) { String s = " ababbbacbcbcca " ; int n = s . length ( ) ; System . out . println ( maxLength ( s , n ) ) ; } }

Index/key variables: j
Accumulator variables: count, i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int NO_OF_CHARS = 256 ; static int firstRepeating ( String str ) { boolean [ ] visited = new boolean [ NO_OF_CHARS ] ; for ( int i = 0 ; i < NO_OF_CHARS ; i ++ ) visited [ i ] = false ; int res = - 1 ; for ( int i = str . length ( ) - 1 ; i >= 0 ; i -- ) { if ( visited [ str . charAt ( i ) ] == false ) visited [ str . charAt ( i ) ] = true ; else res = i ; } return res ; } public static void main ( String [ ] args ) { String str = " geeksforgeeks " ; int index = firstRepeating ( str ) ; if ( index == - 1 ) System . out . printf ( " Either ▁ all ▁ characters ▁ are ▁ " + " distinct ▁ or ▁ string ▁ is ▁ empty " ) ; else System . out . printf ( " First ▁ Repeating ▁ character " + " ▁ is ▁ % c " , str . charAt ( index ) ) ; } }

Index/key variables: NO_OF_CHARS, i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int maxSum ( int arr [ ] , int n , int K ) { int maximum = Integer . MIN_VALUE ; int [ ] sum = new int [ n ] ; for ( int i = n - 1 ; i >= 0 ; i -- ) { if ( i + K < n ) sum [ i ] = sum [ i + K ] + arr [ i ] ; else sum [ i ] = arr [ i ] ; maximum = Math . max ( maximum , sum [ i ] ) ; } return maximum ; } public static void main ( String [ ] args ) { int arr [ ] = { 3 , 6 , 4 , 7 , 2 } ; int n = arr . length ; int K = 2 ; System . out . print ( maxSum ( arr , n , K ) ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int countPairs ( String s1 , int n1 , String s2 , int n2 ) { int [ ] freq1 = new int [ 26 ] ; int [ ] freq2 = new int [ 26 ] ; Arrays . fill ( freq1 , 0 ) ; Arrays . fill ( freq2 , 0 ) ; int i , count = 0 ; for ( i = 0 ; i < n1 ; i ++ ) freq1 [ s1 . charAt ( i ) - ' a ' ] ++ ; for ( i = 0 ; i < n2 ; i ++ ) freq2 [ s2 . charAt ( i ) - ' a ' ] ++ ; for ( i = 0 ; i < 26 ; i ++ ) count += ( Math . min ( freq1 [ i ] , freq2 [ i ] ) ) ; return count ; } public static void main ( String args [ ] ) { String s1 = " geeksforgeeks " , s2 = " platformforgeeks " ; int n1 = s1 . length ( ) , n2 = s2 . length ( ) ; System . out . println ( countPairs ( s1 , n1 , s2 , n2 ) ) ; } }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static void findpair ( int l , int r ) { int c = 0 ; for ( int i = l ; i <= r ; i ++ ) { for ( int j = i + 1 ; j <= r ; j ++ ) { if ( j % i == 0 && j != i ) { System . out . println ( i + " , ▁ " + j ) ; c = 1 ; break ; } } if ( c == 1 ) break ; } } public static void main ( String args [ ] ) { int l = 1 , r = 10 ; findpair ( l , r ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static boolean check ( int arr [ ] , int N , int K ) { HashSet < Integer > unique = new HashSet < Integer > ( ) ; for ( int i = 0 ; i < N ; i ++ ) unique . add ( arr [ i ] ) ; if ( unique . size ( ) == K ) return true ; return false ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 1 , 2 , 3 } ; int N = arr . length ; int K = 3 ; if ( check ( arr , N , K ) ) 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:
import java . util . * ; class GFG { static void findSumPairs ( int a [ ] , int n ) { Map < Integer , Integer > mpp = new HashMap < > ( ) ; for ( int i = 0 ; i < n - 1 ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { mpp . put ( a [ i ] + a [ j ] , mpp . get ( a [ i ] + a [ j ] ) == null ? 1 : mpp . get ( a [ i ] + a [ j ] ) + 1 ) ; } } int occur = 0 ; for ( Map . Entry < Integer , Integer > entry : mpp . entrySet ( ) ) { if ( entry . getValue ( ) > occur ) { occur = entry . getValue ( ) ; } } for ( Map . Entry < Integer , Integer > entry : mpp . entrySet ( ) ) { if ( entry . getValue ( ) == occur ) System . out . println ( entry . getKey ( ) ) ; } } public static void main ( String args [ ] ) { int a [ ] = { 1 , 8 , 3 , 11 , 4 , 9 , 2 , 7 } ; int n = a . length ; findSumPairs ( a , n ) ; } }

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