dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
import java . util . Arrays ; class GFG { static int right = 2 ; static int left = 4 ; static int [ ] [ ] dp = new int [ left ] [ right ] ; static int findSubarraySum ( int ind , int flips , int n , int [ ] a , int k ) { if ( flips > k ) return ( int ) ( - 1e9 ) ; if ( ind == n ) return 0 ; if ( dp [ ind ] [ flips ] != - 1 ) return dp [ ind ] [ flips ] ; int ans = 0 ; ans = Math . max ( 0 , a [ ind ] + findSubarraySum ( ind + 1 , flips , n , a , k ) ) ; ans = Math . max ( ans , - a [ ind ] + findSubarraySum ( ind + 1 , flips + 1 , n , a , k ) ) ; return dp [ ind ] [ flips ] = ans ; } static int findMaxSubarraySum ( int [ ] a , int n , int k ) { for ( int i = 0 ; i < n ; i ++ ) for ( int j = 0 ; j < k + 1 ; j ++ ) dp [ i ] [ j ] = - 1 ; int ans = ( int ) ( - 1e9 ) ; for ( int i = 0 ; i < n ; i ++ ) ans = Math . max ( ans , findSubarraySum ( i , 0 , n , a , k ) ) ; if ( ans == 0 && k == 0 ) return Arrays . stream ( a ) . max ( ) . getAsInt ( ) ; return ans ; } public static void main ( String [ ] args ) { int [ ] a = { - 1 , - 2 , - 100 , - 10 } ; int n = a . length ; int k = 1 ; System . out . println ( findMaxSubarraySum ( a , n , k ) ) ; } }

Index/key variables: flips, i, ind, j, left, right
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int mod = 1000000007 ; static int sumOddFibonacci ( int n ) { int Sum [ ] = new int [ n + 1 ] ; Sum [ 0 ] = 0 ; Sum [ 1 ] = 1 ; Sum [ 2 ] = 2 ; Sum [ 3 ] = 5 ; Sum [ 4 ] = 10 ; Sum [ 5 ] = 23 ; for ( int i = 6 ; i <= n ; i ++ ) { Sum [ i ] = ( ( Sum [ i - 1 ] + ( 4 * Sum [ i - 2 ] ) % mod - ( 4 * Sum [ i - 3 ] ) % mod + mod ) % mod + ( Sum [ i - 4 ] - Sum [ i - 5 ] + mod ) % mod ) % mod ; } return Sum [ n ] ; } public static void main ( String [ ] args ) { int n = 6 ; System . out . println ( sumOddFibonacci ( n ) ) ; }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
public class GFG { static long fun ( int marks [ ] , int n ) { long dp [ ] = new long [ n ] ; int temp ; for ( int i = 0 ; i < n ; i ++ ) dp [ i ] = 1 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( marks [ i ] > marks [ i + 1 ] ) { temp = i ; while ( true ) { if ( ( marks [ temp ] > marks [ temp + 1 ] ) && temp >= 0 ) { if ( dp [ temp ] > dp [ temp + 1 ] ) { temp -= 1 ; continue ; } else { dp [ temp ] = dp [ temp + 1 ] + 1 ; temp -= 1 ; } } else break ; } } else if ( marks [ i ] < marks [ i + 1 ] ) dp [ i + 1 ] = dp [ i ] + 1 ; } int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) sum += dp [ i ] ; return sum ; } public static void main ( String args [ ] ) { int n = 6 ; int marks [ ] = { 1 , 4 , 5 , 2 , 2 , 1 } ; System . out . println ( fun ( marks , n ) ) ; } }

Index/key variables: i, n, temp
Accumulator variables: i, sum, temp
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int solve ( int N , int K ) { int [ ] combo ; combo = new int [ 50 ] ; combo [ 0 ] = 1 ; for ( int i = 1 ; i <= K ; i ++ ) { for ( int j = 0 ; j <= N ; j ++ ) { if ( j >= i ) { combo [ j ] += combo [ j - i ] ; } } } return combo [ N ] ; } public static void main ( String args [ ] ) { int N = 29 ; int K = 5 ; System . out . println ( solve ( N , K ) ) ; solve ( N , K ) ; } }

Index/key variables: N, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
class Test { static int computeLIS ( int circBuff [ ] , int start , int end , int n ) { int LIS [ ] = new int [ n + end - start ] ; for ( int i = start ; i < end ; i ++ ) LIS [ i ] = 1 ; for ( int i = start + 1 ; i < end ; i ++ ) for ( int j = start ; j < i ; j ++ ) if ( circBuff [ i ] > circBuff [ j ] && LIS [ i ] < LIS [ j ] + 1 ) LIS [ i ] = LIS [ j ] + 1 ; int res = Integer . MIN_VALUE ; for ( int i = start ; i < end ; i ++ ) res = Math . max ( res , LIS [ i ] ) ; return res ; } static int LICS ( int arr [ ] , int n ) { int circBuff [ ] = new int [ 2 * n ] ; for ( int i = 0 ; i < n ; i ++ ) circBuff [ i ] = arr [ i ] ; for ( int i = n ; i < 2 * n ; i ++ ) circBuff [ i ] = arr [ i - n ] ; int res = Integer . MIN_VALUE ; for ( int i = 0 ; i < n ; i ++ ) res = Math . max ( computeLIS ( circBuff , i , i + n , n ) , res ) ; return res ; } public static void main ( String args [ ] ) { int arr [ ] = { 1 , 4 , 6 , 2 , 3 } ; System . out . println ( " Length ▁ of ▁ LICS ▁ is ▁ " + LICS ( arr , arr . length ) ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: Test
Java program:
import java . io . * ; import java . util . * ; class GFG { static int min ( int a , int b ) { return a < b ? a : b ; } static int binomialCoeff ( int n , int k ) { int C [ ] = new int [ k + 1 ] ; C [ 0 ] = 1 ; for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = min ( i , k ) ; j > 0 ; j -- ) C [ j ] = C [ j ] + C [ j - 1 ] ; } return C [ k ] ; } public static void main ( String [ ] args ) { int n = 3 , m = 2 ; System . out . println ( " Number ▁ of ▁ Paths : ▁ " + binomialCoeff ( n + m , n ) ) ; } }

Index/key variables: j, k
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int LCIS ( int arr1 [ ] , int n , int arr2 [ ] , int m ) { int table [ ] = new int [ m ] ; for ( int j = 0 ; j < m ; j ++ ) table [ j ] = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int current = 0 ; for ( int j = 0 ; j < m ; j ++ ) { if ( arr1 [ i ] == arr2 [ j ] ) if ( current + 1 > table [ j ] ) table [ j ] = current + 1 ; if ( arr1 [ i ] > arr2 [ j ] ) if ( table [ j ] > current ) current = table [ j ] ; } } int result = 0 ; for ( int i = 0 ; i < m ; i ++ ) if ( table [ i ] > result ) result = table [ i ] ; return result ; } public static void main ( String [ ] args ) { int arr1 [ ] = { 3 , 4 , 9 , 1 } ; int arr2 [ ] = { 5 , 3 , 8 , 9 , 10 , 2 , 1 } ; int n = arr1 . length ; int m = arr2 . length ; System . out . println ( " Length ▁ of ▁ LCIS ▁ is ▁ " + LCIS ( arr1 , n , arr2 , m ) ) ; } }

Index/key variables: i, j, m
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int longComPre ( String arr [ ] , int N ) { int [ ] [ ] freq = new int [ N ] [ 256 ] ; for ( int i = 0 ; i < N ; i ++ ) { int M = arr [ i ] . length ( ) ; for ( int j = 0 ; j < M ; j ++ ) { freq [ i ] [ arr [ i ] . charAt ( j ) ] ++ ; } } int maxLen = 0 ; for ( int j = 0 ; j < 256 ; j ++ ) { int minRowVal = Integer . MAX_VALUE ; for ( int i = 0 ; i < N ; i ++ ) { minRowVal = Math . min ( minRowVal , freq [ i ] [ j ] ) ; } maxLen += minRowVal ; } return maxLen ; } public static void main ( String [ ] args ) { String arr [ ] = { " aabdc " , " abcd " , " aacd " } ; int N = 3 ; System . out . print ( longComPre ( arr , N ) ) ; } }

Index/key variables: N, i, j
Accumulator variables: i, j, maxLen
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int MAX_CHAR = 26 ; static String removeChars ( char arr [ ] , int k ) { int [ ] hash = new int [ MAX_CHAR ] ; int n = arr . length ; for ( int i = 0 ; i < n ; ++ i ) hash [ arr [ i ] - ' a ' ] ++ ; String ans = " " ; for ( int i = 0 ; i < n ; ++ i ) { if ( hash [ arr [ i ] - ' a ' ] != k ) { ans += arr [ i ] ; } } return ans ; } public static void main ( String [ ] args ) { char str [ ] = " geeksforgeeks " . toCharArray ( ) ; int k = 2 ; System . out . print ( removeChars ( str , k ) ) ; } }

Index/key variables: MAX_CHAR, i
Accumulator variables: ans
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void sub_segments ( String str , int n ) { int l = str . length ( ) ; for ( int x = 0 ; x < l ; x += n ) { String newlist = str . substring ( x , x + n ) ; List < Character > arr = new ArrayList < Character > ( ) ; for ( char y : newlist . toCharArray ( ) ) { if ( ! arr . contains ( y ) ) arr . add ( y ) ; } for ( char y : arr ) System . out . print ( y ) ; System . out . println ( ) ; } } public static void main ( String [ ] args ) { String str = " geeksforgeeksgfg " ; int n = 4 ; sub_segments ( str , n ) ; } }

Accumulator variables: x
Iterator variables: x, y
Class/struct names: GFG
Java program:
import java . util . * ; import java . io . * ; class GFG { public static void findWord ( String c , int n ) { int co = 0 , i ; char s [ ] = new char [ n ] ; for ( i = 0 ; i < n ; i ++ ) { if ( i < n / 2 ) co ++ ; else co = n - i ; if ( ( c . charAt ( i ) + co ) <= 122 ) s [ i ] = ( char ) ( ( int ) c . charAt ( i ) + co ) ; else s [ i ] = ( char ) ( ( int ) c . charAt ( i ) + co - 26 ) ; } String str = Arrays . toString ( s ) ; System . out . println ( str ) ; } public static void main ( String args [ ] ) { String s = " abcd " ; findWord ( s , s . length ( ) ) ; } }

Index/key variables: i, n
Accumulator variables: co, i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static boolean equalIgnoreCase ( String str1 , String str2 ) { int i = 0 ; int len1 = str1 . length ( ) ; int len2 = str2 . length ( ) ; if ( len1 != len2 ) return false ; while ( i < len1 ) { if ( str1 . charAt ( i ) == str2 . charAt ( i ) ) { i ++ ; } else if ( ! ( ( str1 . charAt ( i ) >= ' a ' && str1 . charAt ( i ) <= ' z ' ) || ( str1 . charAt ( i ) >= ' A ' && str1 . charAt ( i ) <= ' Z ' ) ) ) { return false ; } else if ( ! ( ( str2 . charAt ( i ) >= ' a ' && str2 . charAt ( i ) <= ' z ' ) || ( str2 . charAt ( i ) >= ' A ' && str2 . charAt ( i ) <= ' Z ' ) ) ) { return false ; } else { if ( str1 . charAt ( i ) >= ' a ' && str1 . charAt ( i ) <= ' z ' ) { if ( str1 . charAt ( i ) - 32 != str2 . charAt ( i ) ) return false ; } else if ( str1 . charAt ( i ) >= ' A ' && str1 . charAt ( i ) <= ' Z ' ) { if ( str1 . charAt ( i ) + 32 != str2 . charAt ( i ) ) return false ; } i ++ ; return true ; static void equalIgnoreCaseUtil ( String str1 , String str2 ) { boolean res = equalIgnoreCase ( str1 , str2 ) ; if ( res == true ) System . out . println ( " Same " ) ; else System . out . println ( " Not ▁ Same " ) ; } public static void main ( String args [ ] ) { String str1 , str2 ; str1 = " Geeks " ; str2 = " geeks " ; equalIgnoreCaseUtil ( str1 , str2 ) ; str1 = " Geek " ; str2 = " geeksforgeeks " ; equalIgnoreCaseUtil ( str1 , str2 ) ; } }

Accumulator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static String maxValue ( char [ ] a , char [ ] b ) { Arrays . sort ( b ) ; int n = a . length ; int m = b . length ; int j = m - 1 ; for ( int i = 0 ; i < n ; i ++ ) { if ( j < 0 ) break ; if ( b [ j ] > a [ i ] ) { a [ i ] = b [ j ] ; j -- ; } } return String . valueOf ( a ) ; } public static void main ( String [ ] args ) { String a = "1234" ; String b = "4321" ; System . out . print ( maxValue ( a . toCharArray ( ) , b . toCharArray ( ) ) ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i
Class/struct names: GFG
Java program:
class GfG { static boolean checkIfUnequal ( int n , int q ) { String s1 = Integer . toString ( n ) ; int a [ ] = new int [ 26 ] ; for ( int i = 0 ; i < s1 . length ( ) ; i ++ ) a [ s1 . charAt ( i ) - '0' ] ++ ; int prod = n * q ; String s2 = Integer . toString ( prod ) ; for ( int i = 0 ; i < s2 . length ( ) ; i ++ ) { if ( a [ s2 . charAt ( i ) - '0' ] > 0 ) return false ; } return true ; } static int countInRange ( int l , int r , int q ) { int count = 0 ; for ( int i = l ; i <= r ; i ++ ) { if ( checkIfUnequal ( i , q ) ) count ++ ; } return count ; } public static void main ( String [ ] args ) { int l = 10 , r = 12 , q = 2 ; System . out . println ( countInRange ( l , r , q ) ) ; } }

Accumulator variables: count, i
Iterator variables: i
Class/struct names: GfG
Java program:
import java . lang . Math ; public class GfG { public static boolean is_possible ( String s ) { int l = s . length ( ) ; int one = 0 , zero = 0 ; for ( int i = 0 ; i < l ; i ++ ) { if ( s . charAt ( i ) == '0' ) zero ++ ; else one ++ ; } if ( l % 2 == 0 ) return ( one == zero ) ; else return ( Math . abs ( one - zero ) == 1 ) ; } public static void main ( String [ ] args ) { String s = "100110" ; if ( is_possible ( s ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } }

Accumulator variables: i, one, zero
Iterator variables: i
Class/struct names: GfG
Java program:
class GFG { static int limit = 255 ; static void countFreq ( String str ) { int [ ] count = new int [ limit + 1 ] ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) count [ str . charAt ( i ) ] ++ ; for ( int i = 0 ; i <= limit ; i ++ ) if ( count [ i ] > 0 ) System . out . println ( ( char ) i + " ▁ " + count [ i ] ) ; } public static void main ( String [ ] args ) { String str = " GeeksforGeeks " ; countFreq ( str ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static String convert ( String s ) { int n = s . length ( ) ; String s1 = " " ; s1 = s1 + Character . toLowerCase ( s . charAt ( 0 ) ) ; for ( int i = 1 ; i < n ; i ++ ) { if ( s . charAt ( i ) == ' ▁ ' && i < n ) { s1 = s1 + " ▁ " + Character . toLowerCase ( s . charAt ( i + 1 ) ) ; i ++ ; } else s1 = s1 + Character . toUpperCase ( s . charAt ( i ) ) ; } return s1 ; } public static void main ( String [ ] args ) { String str = " I ▁ get ▁ intern ▁ at ▁ geeksforgeeks " ; System . out . println ( convert ( str ) ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class Gfg { public static String change_case ( String a ) { String temp = " " ; int l = a . length ( ) ; for ( int i = 0 ; i < l ; i ++ ) { char ch = a . charAt ( i ) ; if ( ch >= ' a ' && ch <= ' z ' ) ch = ( char ) ( 65 + ( int ) ( ch - ' a ' ) ) ; else if ( ch >= ' A ' && ch <= ' Z ' ) ch = ( char ) ( 97 + ( int ) ( ch - ' A ' ) ) ; temp += ch ; } return temp ; } public static String delete_vowels ( String a ) { String temp = " " ; int l = a . length ( ) ; for ( int i = 0 ; i < l ; i ++ ) { char ch = a . charAt ( i ) ; if ( ch != ' a ' && ch != ' e ' && ch != ' i ' && ch != ' o ' && ch != ' u ' && ch != ' A ' && ch != ' E ' && ch != ' O ' && ch != ' U ' && ch != ' I ' ) temp += ch ; } return temp ; } public static String insert_hash ( String a ) { String temp = " " ; int l = a . length ( ) ; char hash = ' # ' ; for ( int i = 0 ; i < l ; i ++ ) { char ch = a . charAt ( i ) ; if ( ( ch >= ' a ' && ch <= ' z ' ) || ( ch >= ' A ' && ch <= ' Z ' ) ) temp = temp + hash + ch ; else temp = temp + ch ; } return temp ; } public static void transformString ( String a ) { String b = delete_vowels ( a ) ; String c = change_case ( b ) ; String d = insert_hash ( c ) ; System . out . println ( d ) ; } public static void main ( String args [ ] ) { String a = " SunshinE ! ! " ; transformString ( a ) ; } }

Accumulator variables: i, temp
Iterator variables: i
Class/struct names: Gfg
Java program:
class GFG { static int reverse ( int num ) { int rev_num = 0 ; while ( num > 0 ) { rev_num = rev_num * 10 + num % 10 ; num = num / 10 ; } return rev_num ; } static int properDivSum ( int num ) { int result = 0 ; for ( int i = 2 ; i <= Math . sqrt ( num ) ; i ++ ) { if ( num % i == 0 ) { if ( i == ( num / i ) ) result += i ; else result += ( i + num / i ) ; } } return ( result + 1 ) ; } static boolean isTcefrep ( int n ) { return properDivSum ( n ) == reverse ( n ) ; } public static void main ( String [ ] args ) { int N = 6 ; if ( isTcefrep ( N ) ) System . out . print ( " Yes " ) ; else System . out . print ( " No " ) ; } }

Accumulator variables: i, result
Iterator variables: i
Class/struct names: GFG
Java program:
public class GFG { static String findNthNo ( int n ) { String res = " " ; while ( n >= 1 ) { if ( ( n & 1 ) == 1 ) { res = res + "3" ; n = ( n - 1 ) / 2 ; } else { res = res + "5" ; n = ( n - 2 ) / 2 ; } } StringBuilder sb = new StringBuilder ( res ) ; sb . reverse ( ) ; return new String ( sb ) ; } public static void main ( String args [ ] ) { int n = 5 ; System . out . print ( findNthNo ( n ) ) ; } }

Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; import java . lang . * ; class GFG { static int findNthNonSquare ( int n ) { double x = ( double ) n ; double ans = x + Math . floor ( 0.5 + Math . sqrt ( x ) ) ; return ( int ) ans ; } public static void main ( String [ ] args ) { int n = 16 ; System . out . print ( " The ▁ " + n + " th ▁ Non - Square ▁ number ▁ is ▁ " ) ; System . out . print ( findNthNonSquare ( n ) ) ; } }

Class/struct names: GFG
Java program:
import java . io . * ; import java . lang . * ; import java . util . * ; class GFG { static int seiresSum ( int n , int [ ] a ) { return n * ( a [ 0 ] * a [ 0 ] - a [ 2 * n - 1 ] * a [ 2 * n - 1 ] ) / ( 2 * n - 1 ) ; } public static void main ( String args [ ] ) { int n = 2 ; int a [ ] = { 1 , 2 , 3 , 4 } ; System . out . println ( seiresSum ( n , a ) ) ; } }

Class/struct names: GFG
Java program:
import java . io . * ; class GFG { public static boolean checkdigit ( int n , int k ) { while ( n != 0 ) { int rem = n % 10 ; if ( rem == k ) return true ; n = n / 10 ; } return false ; } public static int findNthNumber ( int n , int k ) { for ( int i = k + 1 , count = 1 ; count < n ; i ++ ) { if ( checkdigit ( i , k ) || ( i % k == 0 ) ) count ++ ; if ( count == n ) return i ; } return - 1 ; } public static void main ( String [ ] args ) { int n = 10 , k = 2 ; System . out . println ( findNthNumber ( n , k ) ) ; } }

Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { public static int find_permutations ( Vector < Integer > arr ) { int cnt = 0 ; int max_ind = - 1 , min_ind = 10000000 ; int n = arr . size ( ) ; HashMap < Integer , Integer > index_of = new HashMap < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { index_of . put ( arr . get ( i ) , i + 1 ) ; } for ( int i = 1 ; i <= n ; i ++ ) { max_ind = Math . max ( max_ind , index_of . get ( i ) ) ; min_ind = Math . min ( min_ind , index_of . get ( i ) ) ; if ( max_ind - min_ind + 1 == i ) cnt ++ ; } return cnt ; } public static void main ( String [ ] args ) { Vector < Integer > nums = new Vector < Integer > ( ) ; nums . add ( 2 ) ; nums . add ( 3 ) ; nums . add ( 1 ) ; nums . add ( 5 ) ; nums . add ( 4 ) ; System . out . print ( find_permutations ( nums ) ) ; } }

Accumulator variables: cnt, i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int calgcd ( int a , int b ) { if ( b == 0 ) return a ; return calgcd ( b , a % b ) ; } static int getCount ( int [ ] a , int n ) { int gcd = 0 ; for ( int i = 0 ; i < n ; i ++ ) gcd = calgcd ( gcd , a [ i ] ) ; int cnt = 0 ; for ( int i = 1 ; i * i <= gcd ; i ++ ) { if ( gcd % i == 0 ) { if ( i * i == gcd ) cnt ++ ; else cnt += 2 ; } } return cnt ; } public static void main ( String [ ] args ) { int [ ] a = { 4 , 16 , 1024 , 48 } ; int n = a . length ; System . out . println ( getCount ( a , n ) ) ; } }

Index/key variables: i
Accumulator variables: cnt, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { public static int delCost ( String s , int [ ] cost ) { boolean visited [ ] = new boolean [ s . length ( ) ] ; int ans = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( visited [ i ] ) { continue ; } int maxDel = 0 ; int totalCost = 0 ; visited [ i ] = true ; for ( int j = i ; j < s . length ( ) ; j ++ ) { if ( s . charAt ( i ) == s . charAt ( j ) ) { maxDel = Math . max ( maxDel , cost [ j ] ) ; totalCost += cost [ j ] ; visited [ j ] = true ; } } ans += totalCost - maxDel ; } return ans ; } public static void main ( String [ ] args ) { String s = " AAABBB " ; int [ ] cost = { 1 , 2 , 3 , 4 , 5 , 6 } ; System . out . println ( delCost ( s , cost ) ) ; } }

Index/key variables: i, j
Accumulator variables: ans, i, j, totalCost
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void checkXOR ( int arr [ ] , int N ) { if ( N % 2 == 0 ) { int xro = 0 ; for ( int i = 0 ; i < N ; i ++ ) { xro ^= arr [ i ] ; } if ( xro != 0 ) { System . out . println ( - 1 ) ; return ; } for ( int i = 0 ; i < N - 3 ; i += 2 ) { System . out . println ( i + " ▁ " + ( i + 1 ) + " ▁ " + ( i + 2 ) ) ; } for ( int i = 0 ; i < N - 3 ; i += 2 ) { System . out . println ( i + " ▁ " + ( i + 1 ) + " ▁ " + ( N - 1 ) ) ; } } else { for ( int i = 0 ; i < N - 2 ; i += 2 ) { System . out . println ( i + " ▁ " + ( i + 1 ) + " ▁ " + ( i + 2 ) ) ; } for ( int i = 0 ; i < N - 2 ; i += 2 ) { System . out . println ( i + " ▁ " + ( i + 1 ) + " ▁ " + ( N - 1 ) ) ; } } } public static void main ( String [ ] args ) { int arr [ ] = { 4 , 2 , 1 , 7 , 2 } ; int N = arr . length ; checkXOR ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: i, xro
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int make_array_element_even ( int arr [ ] , int N ) { int res = 0 ; int odd_cont_seg = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( arr [ i ] % 2 == 1 ) { odd_cont_seg ++ ; } else { if ( odd_cont_seg > 0 ) { if ( odd_cont_seg % 2 == 0 ) { res += odd_cont_seg / 2 ; } else { res += ( odd_cont_seg / 2 ) + 2 ; } odd_cont_seg = 0 ; } } } if ( odd_cont_seg > 0 ) { if ( odd_cont_seg % 2 == 0 ) { res += odd_cont_seg / 2 ; } else { res += odd_cont_seg / 2 + 2 ; } } return res ; } public static void main ( String [ ] args ) { int arr [ ] = { 2 , 4 , 5 , 11 , 6 } ; int N = arr . length ; System . out . print ( make_array_element_even ( arr , N ) ) ; } }

Index/key variables: i
Accumulator variables: i, odd_cont_seg, res
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { public static int zvalue ( int [ ] nums ) { int m = max_element ( nums ) ; int cnt = 0 ; for ( int i = 0 ; i <= m ; i ++ ) { cnt = 0 ; for ( int j = 0 ; j < nums . length ; j ++ ) { if ( nums [ j ] >= i ) cnt ++ ; } if ( cnt == i ) return i ; } return - 1 ; } public static int max_element ( int [ ] nums ) { int max = nums [ 0 ] ; for ( int i = 1 ; i < nums . length ; i ++ ) max = Math . max ( max , nums [ i ] ) ; return max ; } public static void main ( String args [ ] ) { int [ ] nums = { 7 , 8 , 9 , 0 , 0 , 1 } ; System . out . println ( zvalue ( nums ) ) ; } }

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