dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
import java . util . * ; class GFG { static int root ( int arr [ ] , int i ) { while ( arr [ i ] != i ) { arr [ i ] = arr [ arr [ i ] ] ; i = arr [ i ] ; } return i ; } static void weighted_union ( int arr [ ] , int rank [ ] , int a , int b ) { int root_a = root ( arr , a ) ; int root_b = root ( arr , b ) ; if ( rank [ root_a ] < rank [ root_b ] ) { arr [ root_a ] = arr [ root_b ] ; rank [ root_b ] += rank [ root_a ] ; } else { arr [ root_b ] = arr [ root_a ] ; rank [ root_a ] += rank [ root_b ] ; } } static boolean areSame ( int arr [ ] , int a , int b ) { return ( root ( arr , a ) == root ( arr , b ) ) ; } static void query ( int type , int x , int y , int arr [ ] , int rank [ ] ) { if ( type == 1 ) { if ( areSame ( arr , x , y ) == true ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } else if ( type == 2 ) { if ( areSame ( arr , x , y ) == false ) weighted_union ( arr , rank , x , y ) ; } } public static void main ( String [ ] args ) { int n = 7 ; int [ ] arr = new int [ n ] ; int [ ] rank = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { arr [ i ] = i ; rank [ i ] = 1 ; } int q = 11 ; query ( 1 , 0 , 1 , arr , rank ) ; query ( 2 , 0 , 1 , arr , rank ) ; query ( 2 , 1 , 2 , arr , rank ) ; query ( 1 , 0 , 2 , arr , rank ) ; query ( 2 , 0 , 2 , arr , rank ) ; query ( 2 , 2 , 3 , arr , rank ) ; query ( 2 , 3 , 4 , arr , rank ) ; query ( 1 , 0 , 5 , arr , rank ) ; query ( 2 , 4 , 5 , arr , rank ) ; query ( 2 , 5 , 6 , arr , rank ) ; query ( 1 , 2 , 6 , arr , rank ) ; } }

Index/key variables: i, n, root_a, root_b
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . LinkedList ; import java . util . Queue ; class Node { int data ; Node left , right ; public Node ( int item ) { data = item ; left = right = null ; } } class BinaryTree { Node root ; void printSpecificLevelOrder ( Node node ) { if ( node == null ) return ; System . out . print ( node . data ) ; if ( node . left != null ) System . out . print ( " ▁ " + node . left . data + " ▁ " + node . right . data ) ; if ( node . left . left == null ) return ; Queue < Node > q = new LinkedList < Node > ( ) ; q . add ( node . left ) ; q . add ( node . right ) ; Node first = null , second = null ; while ( ! q . isEmpty ( ) ) { first = q . peek ( ) ; q . remove ( ) ; second = q . peek ( ) ; q . remove ( ) ; System . out . print ( " ▁ " + first . left . data + " ▁ " + second . right . data ) ; System . out . print ( " ▁ " + first . right . data + " ▁ " + second . left . data ) ; if ( first . left . left != null ) { q . add ( first . left ) ; q . add ( second . right ) ; q . add ( first . right ) ; q . add ( second . left ) ; } } } public static void main ( String args [ ] ) { BinaryTree tree = new BinaryTree ( ) ; tree . root = new Node ( 1 ) ; tree . root . left = new Node ( 2 ) ; tree . root . right = new Node ( 3 ) ; tree . root . left . left = new Node ( 4 ) ; tree . root . left . right = new Node ( 5 ) ; tree . root . right . left = new Node ( 6 ) ; tree . root . right . right = new Node ( 7 ) ; tree . root . left . left . left = new Node ( 8 ) ; tree . root . left . left . right = new Node ( 9 ) ; tree . root . left . right . left = new Node ( 10 ) ; tree . root . left . right . right = new Node ( 11 ) ; tree . root . right . left . left = new Node ( 12 ) ; tree . root . right . left . right = new Node ( 13 ) ; tree . root . right . right . left = new Node ( 14 ) ; tree . root . right . right . right = new Node ( 15 ) ; tree . root . left . left . left . left = new Node ( 16 ) ; tree . root . left . left . left . right = new Node ( 17 ) ; tree . root . left . left . right . left = new Node ( 18 ) ; tree . root . left . left . right . right = new Node ( 19 ) ; tree . root . left . right . left . left = new Node ( 20 ) ; tree . root . left . right . left . right = new Node ( 21 ) ; tree . root . left . right . right . left = new Node ( 22 ) ; tree . root . left . right . right . right = new Node ( 23 ) ; tree . root . right . left . left . left = new Node ( 24 ) ; tree . root . right . left . left . right = new Node ( 25 ) ; tree . root . right . left . right . left = new Node ( 26 ) ; tree . root . right . left . right . right = new Node ( 27 ) ; tree . root . right . right . left . left = new Node ( 28 ) ; tree . root . right . right . left . right = new Node ( 29 ) ; tree . root . right . right . right . left = new Node ( 30 ) ; tree . root . right . right . right . right = new Node ( 31 ) ; System . out . println ( " Specific ▁ Level ▁ Order ▁ traversal ▁ of ▁ binary " + " tree ▁ is ▁ " ) ; tree . printSpecificLevelOrder ( tree . root ) ; } }

Class/struct names: BinaryTree, Node
Java program:
import java . io . * ; import java . lang . * ; import java . util . * ; import java . util . LinkedList ; class MaxFlow { static final int V = 6 ; boolean bfs ( int rGraph [ ] [ ] , int s , int t , int parent [ ] ) { boolean visited [ ] = new boolean [ V ] ; for ( int i = 0 ; i < V ; ++ i ) visited [ i ] = false ; LinkedList < Integer > queue = new LinkedList < Integer > ( ) ; queue . add ( s ) ; visited [ s ] = true ; parent [ s ] = - 1 ; while ( queue . size ( ) != 0 ) { int u = queue . poll ( ) ; for ( int v = 0 ; v < V ; v ++ ) { if ( visited [ v ] == false && rGraph [ u ] [ v ] > 0 ) { if ( v == t ) { parent [ v ] = u ; return true ; } queue . add ( v ) ; parent [ v ] = u ; visited [ v ] = true ; } } } return false ; } int fordFulkerson ( int graph [ ] [ ] , int s , int t ) { int u , v ; int rGraph [ ] [ ] = new int [ V ] [ V ] ; for ( u = 0 ; u < V ; u ++ ) for ( v = 0 ; v < V ; v ++ ) rGraph [ u ] [ v ] = graph [ u ] [ v ] ; int parent [ ] = new int [ V ] ; int max_flow = 0 ; while ( bfs ( rGraph , s , t , parent ) ) { int path_flow = Integer . MAX_VALUE ; for ( v = t ; v != s ; v = parent [ v ] ) { u = parent [ v ] ; path_flow = Math . min ( path_flow , rGraph [ u ] [ v ] ) ; } for ( v = t ; v != s ; v = parent [ v ] ) { u = parent [ v ] ; rGraph [ u ] [ v ] -= path_flow ; rGraph [ v ] [ u ] += path_flow ; } max_flow += path_flow ; } return max_flow ; } public static void main ( String [ ] args ) throws java . lang . Exception { int graph [ ] [ ] = new int [ ] [ ] { { 0 , 16 , 13 , 0 , 0 , 0 } , { 0 , 0 , 10 , 12 , 0 , 0 } , { 0 , 4 , 0 , 0 , 14 , 0 } , { 0 , 0 , 9 , 0 , 0 , 20 } , { 0 , 0 , 0 , 7 , 0 , 4 } , { 0 , 0 , 0 , 0 , 0 , 0 } } ; MaxFlow m = new MaxFlow ( ) ; System . out . println ( " The ▁ maximum ▁ possible ▁ flow ▁ is ▁ " + m . fordFulkerson ( graph , 0 , 5 ) ) ; } }

Index/key variables: V, i, s, u, v
Accumulator variables: max_flow, u, v
Iterator variables: i, u, v
Class/struct names: MaxFlow
Java program:
import java . util . * ; class GFG { static int V = 8 ; static boolean bfs ( int rGraph [ ] [ ] , int s , int t , int parent [ ] ) { boolean [ ] visited = new boolean [ V ] ; Queue < Integer > q = new LinkedList < > ( ) ; q . add ( s ) ; visited [ s ] = true ; parent [ s ] = - 1 ; while ( ! q . isEmpty ( ) ) { int u = q . peek ( ) ; q . remove ( ) ; for ( int v = 0 ; v < V ; v ++ ) { if ( visited [ v ] == false && rGraph [ u ] [ v ] > 0 ) { q . add ( v ) ; parent [ v ] = u ; visited [ v ] = true ; } } } return ( visited [ t ] == true ) ; } static int findDisjointPaths ( int graph [ ] [ ] , int s , int t ) { int u , v ; int [ ] [ ] rGraph = new int [ V ] [ V ] ; for ( u = 0 ; u < V ; u ++ ) for ( v = 0 ; v < V ; v ++ ) rGraph [ u ] [ v ] = graph [ u ] [ v ] ; int [ ] parent = new int [ V ] ; int max_flow = 0 ; while ( bfs ( rGraph , s , t , parent ) ) { int path_flow = Integer . MAX_VALUE ; for ( v = t ; v != s ; v = parent [ v ] ) { u = parent [ v ] ; path_flow = Math . min ( path_flow , rGraph [ u ] [ v ] ) ; } for ( v = t ; v != s ; v = parent [ v ] ) { u = parent [ v ] ; rGraph [ u ] [ v ] -= path_flow ; rGraph [ v ] [ u ] += path_flow ; } max_flow += path_flow ; } return max_flow ; } public static void main ( String [ ] args ) { int graph [ ] [ ] = { { 0 , 1 , 1 , 1 , 0 , 0 , 0 , 0 } , { 0 , 0 , 1 , 0 , 0 , 0 , 0 , 0 } , { 0 , 0 , 0 , 1 , 0 , 0 , 1 , 0 } , { 0 , 0 , 0 , 0 , 0 , 0 , 1 , 0 } , { 0 , 0 , 1 , 0 , 0 , 0 , 0 , 1 } , { 0 , 1 , 0 , 0 , 0 , 0 , 0 , 1 } , { 0 , 0 , 0 , 0 , 0 , 1 , 0 , 1 } , { 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } } ; int s = 0 ; int t = 7 ; System . out . println ( " There ▁ can ▁ be ▁ maximum ▁ " + findDisjointPaths ( graph , s , t ) + " ▁ edge - disjoint ▁ paths ▁ from ▁ " + s + " ▁ to ▁ " + t ) ; } }

Index/key variables: V, s, t, u, v
Accumulator variables: max_flow, u, v
Iterator variables: u, v
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int M = 3 ; static int N = 3 ; static boolean bpm ( int table [ ] [ ] , int u , boolean seen [ ] , int matchR [ ] ) { for ( int v = 0 ; v < N ; v ++ ) { if ( table [ u ] [ v ] > 0 && ! seen [ v ] ) { seen [ v ] = true ; if ( matchR [ v ] < 0 || bpm ( table , matchR [ v ] , seen , matchR ) ) { matchR [ v ] = u ; return true ; } } } return false ; } static int maxBPM ( int table [ ] [ ] ) { int [ ] matchR = new int [ N ] ; Arrays . fill ( matchR , - 1 ) ; int result = 0 ; for ( int u = 0 ; u < M ; u ++ ) { boolean [ ] seen = new boolean [ N ] ; Arrays . fill ( seen , false ) ; if ( bpm ( table , u , seen , matchR ) ) result ++ ; } System . out . println ( " The ▁ number ▁ of ▁ maximum ▁ packets " + " ▁ sent ▁ in ▁ the ▁ time ▁ slot ▁ is ▁ " + result ) ; for ( int x = 0 ; x < N ; x ++ ) if ( matchR [ x ] + 1 != 0 ) System . out . println ( " T " + ( matchR [ x ] + 1 ) + " - > ▁ R " + ( x + 1 ) ) ; return result ; } public static void main ( String [ ] args ) { int table [ ] [ ] = { { 0 , 2 , 0 } , { 3 , 0 , 1 } , { 2 , 4 , 0 } } ; maxBPM ( table ) ; } }

Index/key variables: N, u, v, x
Accumulator variables: result, u, v, x
Iterator variables: u, v, x
Class/struct names: GFG
Java program:
import java . util . * ; class Node { int data ; Node left , right ; public Node ( int data ) { this . data = data ; left = right = null ; } } class BinaryTree { Node root ; void printSpecificLevelOrderUtil ( Node root , Stack < Node > s ) { if ( root == null ) return ; Queue < Node > q = new LinkedList < Node > ( ) ; q . add ( root . left ) ; q . add ( root . right ) ; Node first = null , second = null ; while ( ! q . isEmpty ( ) ) { first = q . peek ( ) ; q . poll ( ) ; second = q . peek ( ) ; q . poll ( ) ; s . push ( second . left ) ; s . push ( first . right ) ; s . push ( second . right ) ; s . push ( first . left ) ; if ( first . left . left != null ) { q . add ( first . right ) ; q . add ( second . left ) ; q . add ( first . left ) ; q . add ( second . right ) ; } } } void printSpecificLevelOrder ( Node root ) { Stack < Node > s = new Stack < Node > ( ) ; s . push ( root ) ; if ( root . left != null ) { s . push ( root . right ) ; s . push ( root . left ) ; } if ( root . left . left != null ) printSpecificLevelOrderUtil ( root , s ) ; while ( ! s . empty ( ) ) { System . out . print ( s . peek ( ) . data + " ▁ " ) ; s . pop ( ) ; } } public static void main ( String [ ] args ) { BinaryTree tree = new BinaryTree ( ) ; tree . root = new Node ( 1 ) ; tree . root . left = new Node ( 2 ) ; tree . root . right = new Node ( 3 ) ; System . out . println ( " Specific ▁ Level ▁ Order ▁ Traversal ▁ " + " of ▁ Binary ▁ Tree ▁ is ▁ " ) ; tree . printSpecificLevelOrder ( tree . root ) ; }

Class/struct names: BinaryTree, Node
Java program:
if ( inMST [ v ] == false && key [ v ] > weight ) { key [ v ] = weight ; pq . add ( new Pair < Integer , Integer > ( key [ v ] , v ) ) ; parent [ v ] = u ; }

Index/key variables: v
Java program:
import java . util . * ; class GFG { static int maxindex ( int [ ] dist , int n ) { int mi = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( dist [ i ] > dist [ mi ] ) mi = i ; } return mi ; } static void selectKcities ( int n , int weights [ ] [ ] , int k ) { int [ ] dist = new int [ n ] ; ArrayList < Integer > centers = new ArrayList < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { dist [ i ] = Integer . MAX_VALUE ; } int max = 0 ; for ( int i = 0 ; i < k ; i ++ ) { centers . add ( max ) ; for ( int j = 0 ; j < n ; j ++ ) { dist [ j ] = Math . min ( dist [ j ] , weights [ max ] [ j ] ) ; } max = maxindex ( dist , n ) ; } System . out . println ( dist [ max ] ) ; for ( int i = 0 ; i < centers . size ( ) ; i ++ ) { System . out . print ( centers . get ( i ) + " ▁ " ) ; } System . out . print ( "NEW_LINE"); } public static void main ( String [ ] args ) { int n = 4 ; int [ ] [ ] weights = new int [ ] [ ] { { 0 , 4 , 8 , 5 } , { 4 , 0 , 10 , 7 } , { 8 , 10 , 0 , 9 } , { 5 , 7 , 9 , 0 } } ; int k = 2 ; selectKcities ( n , weights , k ) ; } }

Index/key variables: i, j, max, mi, n
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static class Node { int data ; Node left ; Node right ; Node ( int value ) { data = value ; left = null ; right = null ; } } ; static void specific_level_order_traversal ( Node root ) { Queue < Node > q = new LinkedList < > ( ) ; Stack < Vector < Integer > > s = new Stack < Vector < Integer > > ( ) ; q . add ( root ) ; int sz ; while ( q . size ( ) > 0 ) { Vector < Integer > v = new Vector < Integer > ( ) ; sz = q . size ( ) ; for ( int i = 0 ; i < sz ; ++ i ) { Node temp = q . peek ( ) ; q . remove ( ) ; v . add ( temp . data ) ; if ( temp . left != null ) q . add ( temp . left ) ; if ( temp . right != null ) q . add ( temp . right ) ; } s . push ( v ) ; } while ( s . size ( ) > 0 ) { Vector < Integer > v = s . peek ( ) ; s . pop ( ) ; for ( int i = 0 , j = v . size ( ) - 1 ; i < j ; ++ i ) { System . out . print ( v . get ( i ) + " ▁ " + v . get ( j ) + " ▁ " ) ; j -- ; } } System . out . println ( root . data ) ; } public static void main ( String args [ ] ) { Node root = new Node ( 1 ) ; root . left = new Node ( 2 ) ; root . right = new Node ( 3 ) ; System . out . println ( " Specific ▁ Level ▁ Order ▁ traversal " + " ▁ of ▁ binary ▁ tree ▁ is " ) ; specific_level_order_traversal ( root ) ; } }

Accumulator variables: j
Iterator variables: i
Class/struct names: GFG, Node
Java program:
import java . io . * ; class Directed { int V = 4 ; void multiply ( int A [ ] [ ] , int B [ ] [ ] , int C [ ] [ ] ) { for ( int i = 0 ; i < V ; i ++ ) { for ( int j = 0 ; j < V ; j ++ ) { C [ i ] [ j ] = 0 ; for ( int k = 0 ; k < V ; k ++ ) { C [ i ] [ j ] += A [ i ] [ k ] * B [ k ] [ j ] ; } } } } int getTrace ( int graph [ ] [ ] ) { int trace = 0 ; for ( int i = 0 ; i < V ; i ++ ) { trace += graph [ i ] [ i ] ; } return trace ; } int triangleInGraph ( int graph [ ] [ ] ) { int [ ] [ ] aux2 = new int [ V ] [ V ] ; int [ ] [ ] aux3 = new int [ V ] [ V ] ; for ( int i = 0 ; i < V ; ++ i ) { for ( int j = 0 ; j < V ; ++ j ) { aux2 [ i ] [ j ] = aux3 [ i ] [ j ] = 0 ; } } multiply ( graph , graph , aux2 ) ; multiply ( graph , aux2 , aux3 ) ; int trace = getTrace ( aux3 ) ; return trace / 6 ; } public static void main ( String args [ ] ) { Directed obj = new Directed ( ) ; int graph [ ] [ ] = { { 0 , 1 , 1 , 0 } , { 1 , 0 , 1 , 1 } , { 1 , 1 , 0 , 1 } , { 0 , 1 , 1 , 0 } } ; System . out . println ( " Total ▁ number ▁ of ▁ Triangle ▁ in ▁ Graph ▁ : ▁ " + obj . triangleInGraph ( graph ) ) ; } }

Index/key variables: V, i, j, k
Accumulator variables: i, j, k, trace
Iterator variables: i, j, k
Class/struct names: Directed
Java program:
import java . util . * ; import java . lang . * ; public class GfG { public final static int SIZE = 26 ; public static int binomialCoeff ( int n , int k ) { int res = 1 ; if ( k > n - k ) k = n - k ; for ( int i = 0 ; i < k ; ++ i ) { res *= ( n - i ) ; res /= ( i + 1 ) ; } return res ; } public static int countSubsequences ( String str , String str3 ) { int [ ] freq1 = new int [ SIZE ] ; int [ ] freq2 = new int [ SIZE ] ; char [ ] str1 = str . toCharArray ( ) ; char [ ] str2 = str3 . toCharArray ( ) ; int n1 = str . length ( ) ; int n2 = str3 . length ( ) ; for ( int i = 0 ; i < n1 ; i ++ ) freq1 [ str1 [ i ] - ' a ' ] ++ ; for ( int i = 0 ; i < n2 ; i ++ ) freq2 [ str2 [ i ] - ' a ' ] ++ ; int count = 1 ; for ( int i = 0 ; i < SIZE ; i ++ ) if ( freq2 [ i ] != 0 ) { if ( freq2 [ i ] <= freq1 [ i ] ) count = count * binomialCoeff ( freq1 [ i ] , freq2 [ i ] ) ; else return 0 ; } return count ; } public static void main ( String argc [ ] ) { String str1 = " abacd " ; String str2 = " abc " ; System . out . println ( " Count ▁ = ▁ " + countSubsequences ( str1 , str2 ) ) ; } }

Index/key variables: SIZE, i
Accumulator variables: i, res
Iterator variables: i
Class/struct names: GfG
Java program:
class GFG { static int [ ] fwd = new int [ 100 ] ; static int [ ] bwd = new int [ 100 ] ; static void preProcess ( String a , String b ) { int n = a . length ( ) ; int j = 0 ; for ( int i = 1 ; i <= a . length ( ) ; i ++ ) { if ( j < b . length ( ) && a . charAt ( i - 1 ) == b . charAt ( j ) ) { j ++ ; } fwd [ i ] = j ; } j = 0 ; for ( int i = a . length ( ) ; i >= 1 ; i -- ) { if ( j < b . length ( ) && a . charAt ( i - 1 ) == b . charAt ( b . length ( ) - j - 1 ) ) { j ++ ; } bwd [ i ] = j ; } } static void query ( String a , String b , int x , int y ) { if ( ( x - 1 + a . length ( ) - y ) < b . length ( ) ) { System . out . print ( "NoNEW_LINE"); return ; } if ( fwd [ x - 1 ] + bwd [ y + 1 ] >= b . length ( ) ) { System . out . print ( "YesNEW_LINE"); } else { System . out . print ( "NoNEW_LINE"); } } public static void main ( String [ ] args ) { String a = " abcabcxy " , b = " acy " ; preProcess ( a , b ) ; int x = 2 , y = 5 ; query ( a , b , x , y ) ; x = 3 ; y = 6 ; query ( a , b , x , y ) ; } }

Index/key variables: i
Accumulator variables: i, j
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; import java . lang . * ; public class GfG { public static int findOccurrences ( String str1 , String substr1 ) { int counter = 0 ; char [ ] str = str1 . toCharArray ( ) ; char [ ] substr = substr1 . toCharArray ( ) ; for ( int i = 0 ; i < str1 . length ( ) ; i ++ ) { if ( str [ i ] == substr [ 0 ] ) { for ( int j = i + 1 ; j < str1 . length ( ) ; j ++ ) { if ( str [ j ] == substr [ 1 ] ) { for ( int k = j + 1 ; k < str1 . length ( ) ; k ++ ) { if ( str [ k ] == substr [ 2 ] ) counter ++ ; } } } } } return counter ; } public static void main ( String argc [ ] ) { String str = " GFGFGYSYIOIWIN " ; String substr = " GFG " ; System . out . println ( findOccurrences ( str , substr ) ) ; } }

Index/key variables: i, j, k
Accumulator variables: counter, i, j, k
Iterator variables: i, j, k
Class/struct names: GfG
Java program:
import java . util . * ; import java . lang . * ; public class GfG { public static int findOccurrences ( String str1 , String substr1 ) { int n = str1 . length ( ) ; char [ ] str = str1 . toCharArray ( ) ; char [ ] substr = substr1 . toCharArray ( ) ; int [ ] preLeft = new int [ n ] ; int [ ] preRight = new int [ n ] ; if ( str [ 0 ] == substr [ 0 ] ) preLeft [ 0 ] ++ ; for ( int i = 1 ; i < n ; i ++ ) { if ( str [ i ] == substr [ 0 ] ) preLeft [ i ] = preLeft [ i - 1 ] + 1 ; else preLeft [ i ] = preLeft [ i - 1 ] ; } if ( str [ n - 1 ] == substr [ 2 ] ) preRight [ n - 1 ] ++ ; for ( int i = n - 2 ; i >= 0 ; i -- ) { if ( str [ i ] == substr [ 2 ] ) preRight [ i ] = preRight [ i + 1 ] + 1 ; else preRight [ i ] = preRight [ i + 1 ] ; } int counter = 0 ; for ( int i = 1 ; i < n - 1 ; i ++ ) { if ( str [ i ] == str [ 1 ] ) { int total = preLeft [ i - 1 ] * preRight [ i + 1 ] ; counter += total ; } } return counter ; } public static void main ( String argc [ ] ) { String str = " GFGFGYSYIOIWIN " ; String substr = " GFG " ; System . out . println ( findOccurrences ( str , substr ) ) ; } }

Index/key variables: i, n
Accumulator variables: counter, i
Iterator variables: i
Class/struct names: GfG
Java program:
class GFG { static void largestPalin ( char num [ ] , int n ) { if ( n <= 3 ) return ; int mid = n / 2 - 1 ; int [ ] rightMax = new int [ mid + 1 ] ; int right ; rightMax [ mid ] = - 1 ; right = mid ; for ( int i = mid - 1 ; i >= 0 ; i -- ) { if ( num [ i ] < num [ right ] ) rightMax [ i ] = right ; else { rightMax [ i ] = - 1 ; right = i ; } } for ( int i = 0 ; i <= mid ; i ++ ) { if ( rightMax [ i ] != - 1 ) { swap ( num , i , rightMax [ i ] ) ; swap ( num , n - i - 1 , n - rightMax [ i ] - 1 ) ; break ; } } } static char [ ] swap ( char [ ] arr , int i , int j ) { char temp = arr [ i ] ; arr [ i ] = arr [ j ] ; arr [ j ] = temp ; return arr ; } public static void main ( String [ ] args ) { char num [ ] = "4697557964" . toCharArray ( ) ; int n = num . length ; largestPalin ( num , n ) ; System . out . println ( " Largest ▁ Palindrome : ▁ " + String . valueOf ( num ) ) ; } }

Index/key variables: i, j, mid, right
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GeeksforGeeks { static String compute ( String str , int n ) { String reverseAlphabet = " zyxwvutsrqponmlkjihgfedcba " ; int l = str . length ( ) ; String answer = " " ; for ( int i = 0 ; i < n ; i ++ ) answer = answer + str . charAt ( i ) ; for ( int i = n ; i < l ; i ++ ) answer = answer + reverseAlphabet . charAt ( str . charAt ( i ) - ' a ' ) ; return answer ; } public static void main ( String args [ ] ) { String str = " pneumonia " ; int n = 4 ; System . out . print ( compute ( str , n - 1 ) ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GeeksforGeeks
Java program:
import java . util . * ; public class GFG { static class Pair { int first , second ; Pair ( int f , int s ) { first = f ; second = s ; } } static boolean isBipartite ( int V , ArrayList < ArrayList < Integer > > adj ) { int col [ ] = new int [ V ] ; Arrays . fill ( col , - 1 ) ; Queue < Pair > q = new LinkedList < Pair > ( ) ; for ( int i = 0 ; i < V ; i ++ ) { if ( col [ i ] == - 1 ) { q . add ( new Pair ( i , 0 ) ) ; col [ i ] = 0 ; while ( ! q . isEmpty ( ) ) { Pair p = q . peek ( ) ; q . poll ( ) ; int v = p . first ; int c = p . second ; for ( int j : adj . get ( v ) ) { if ( col [ j ] == c ) return false ; if ( col [ j ] == - 1 ) { col [ j ] = ( c == 1 ) ? 0 : 1 ; q . add ( new Pair ( j , col [ j ] ) ) ; } } } } } return true ; } public static void main ( String args [ ] ) { int V , E ; V = 4 ; E = 8 ; ArrayList < ArrayList < Integer > > adj = new ArrayList < ArrayList < Integer > > ( ) ; for ( int i = 0 ; i < V ; i ++ ) { adj . add ( new ArrayList < Integer > ( ) ) ; } adj . get ( 0 ) . add ( 1 ) ; adj . get ( 0 ) . add ( 3 ) ; adj . get ( 1 ) . add ( 0 ) ; adj . get ( 1 ) . add ( 2 ) ; adj . get ( 2 ) . add ( 1 ) ; adj . get ( 2 ) . add ( 3 ) ; adj . get ( 3 ) . add ( 0 ) ; adj . get ( 3 ) . add ( 2 ) ; boolean ans = isBipartite ( V , adj ) ; if ( ans ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } }

Index/key variables: V, i, j
Accumulator variables: i
Iterator variables: i, j
Class/struct names: GFG, Pair
Java program:
class GFG { static void findString ( String str , int n , int k ) { if ( k == 0 ) { System . out . println ( str ) ; ; return ; } String str2 = str ; int p = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( str2 . charAt ( i ) != ' a ' ) { str2 = str2 . substring ( 0 , i ) + ' a ' + str2 . substring ( i + 1 ) ; p ++ ; if ( p == k ) break ; } } if ( p < k ) { for ( int i = n - 1 ; i >= 0 ; i -- ) if ( str . charAt ( i ) == ' a ' ) { str2 = str2 . substring ( 0 , i ) + ' b ' + str2 . substring ( i + 1 ) ; p ++ ; if ( p == k ) break ; } } System . out . println ( str2 ) ; } public static void main ( String [ ] args ) { String str = " pqrs " ; int n = str . length ( ) ; int k = 2 ; findString ( str , n , k ) ; } }

Accumulator variables: i, p
Iterator variables: i
Class/struct names: GFG