dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
import java . util . * ; import java . lang . * ; public class GfG { public static boolean isEven ( String s1 ) { int l = s1 . length ( ) ; char [ ] s = s1 . toCharArray ( ) ; boolean dotSeen = false ; for ( int i = l - 1 ; i >= 0 ; i -- ) { if ( s [ i ] == '0' && dotSeen == false ) continue ; if ( s [ i ] == ' . ' ) { dotSeen = true ; continue ; } if ( ( s [ i ] - '0' ) % 2 == 0 ) return true ; return false ; } return false ; } public static void main ( String argc [ ] ) { String s = "100.70" ; if ( isEven ( s ) ) System . out . println ( " Even " ) ; else System . out . println ( " Odd " ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Boolean variables: dotSeen
Class/struct names: GfG
Java program:
class GFG { static int minCost ( char [ ] s ) { boolean alphabets [ ] = new boolean [ 26 ] ; for ( int i = 0 ; i < s . length ; i ++ ) { alphabets [ ( int ) s [ i ] - 97 ] = true ; } int count = 0 ; for ( int i = 0 ; i < 26 ; i ++ ) { if ( alphabets [ i ] ) { count ++ ; } } return count ; } public static void main ( String [ ] args ) { String s = " geeksforgeeks " ; System . out . println ( " Total ▁ cost ▁ to ▁ construct ▁ " + s + " ▁ is ▁ " + minCost ( s . toCharArray ( ) ) ) ; } }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . HashMap ; import java . util . Map ; class GFG { static class Node { int data ; Node left , right ; } ; static Node newnode ( int data ) { Node node = new Node ( ) ; node . data = data ; node . left = node . right = null ; return ( node ) ; } static void pathCountUtil ( Node node , HashMap < Integer , Integer > m , int path_len ) { if ( node == null ) return ; if ( node . left == null && node . right == null ) { if ( ! m . containsKey ( path_len ) ) m . put ( path_len , 0 ) ; m . put ( path_len , m . get ( path_len ) + 1 ) ; return ; } pathCountUtil ( node . left , m , path_len + 1 ) ; pathCountUtil ( node . right , m , path_len + 1 ) ; } static void pathCounts ( Node root ) { HashMap < Integer , Integer > m = new HashMap < > ( ) ; pathCountUtil ( root , m , 1 ) ; for ( Map . Entry < Integer , Integer > entry : m . entrySet ( ) ) { System . out . printf ( "%d paths have length %dNEW_LINE", entry . getValue ( ) , entry . getKey ( ) ) ; } } public static void main ( String [ ] args ) { Node root = newnode ( 8 ) ; root . left = newnode ( 5 ) ; root . right = newnode ( 4 ) ; root . left . left = newnode ( 9 ) ; root . left . right = newnode ( 7 ) ; root . right . right = newnode ( 11 ) ; root . right . right . left = newnode ( 3 ) ; pathCounts ( root ) ; } }

Class/struct names: GFG, Node
Java program:
import java . io . * ; class GFG { static void checkingPossibility ( int a [ ] , int n , String s ) { int mark [ ] = new int [ a [ 0 ] * n ] ; int start = 0 ; int possible = 1 ; while ( start >= 0 && start < n ) { if ( s == " < " ) { if ( mark [ start ] == 0 ) { mark [ start ] = 1 ; start -= a [ start ] ; } else { possible = 0 ; break ; } } else { if ( mark [ start ] == 0 ) { mark [ start ] = 1 ; start += a [ start ] ; } else { possible = 0 ; break ; } } } if ( possible == 0 ) System . out . print ( " it ▁ stays ▁ inside ▁ forever " ) ; else System . out . print ( " comes ▁ out " ) ; } public static void main ( String [ ] args ) { int n = 2 ; String s = " > < " ; int a [ ] = { 1 , 2 } ; checkingPossibility ( a , n , s ) ; } }

Index/key variables: start
Accumulator variables: start
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void removeDuplicates ( char [ ] S ) { int n = S . length ; if ( n < 2 ) { return ; } int j = 0 ; for ( int i = 1 ; i < n ; i ++ ) { if ( S [ j ] != S [ i ] ) { j ++ ; S [ j ] = S [ i ] ; } } System . out . println ( Arrays . copyOfRange ( S , 0 , j + 1 ) ) ; } public static void main ( String [ ] args ) { char S1 [ ] = " geeksforgeeks " . toCharArray ( ) ; removeDuplicates ( S1 ) ; char S2 [ ] = " aabcca " . toCharArray ( ) ; removeDuplicates ( S2 ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; public class Main { static String simplify ( String path ) { Vector < String > v = new Vector < String > ( ) ; int n = path . length ( ) ; String ans = " " ; for ( int i = 0 ; i < n ; i ++ ) { String dir = " " ; while ( i < n && path . charAt ( i ) != ' / ' ) { dir += path . charAt ( i ) ; i ++ ; } if ( dir . equals ( " . . " ) ) { if ( v . size ( ) != 0 ) { v . remove ( v . size ( ) - 1 ) ; } } else if ( dir . equals ( " . " ) || dir . equals ( " " ) ) { } else { v . add ( dir ) ; } } for ( String i : v ) { ans += " / " + i ; } if ( ans == " " ) return " / " ; return ans ; } public static void main ( String [ ] args ) { String str = " / a / . / b / . . / . . / c / " ; String res = simplify ( str ) ; System . out . print ( res ) ; } }

Accumulator variables: ans, dir, i
Iterator variables: i
Class/struct names: Main
Java program:
class GFG { final static int NO_OF_CHARS = 256 ; static int max_distinct_char ( String str , int n ) { int count [ ] = new int [ NO_OF_CHARS ] ; for ( int i = 0 ; i < n ; i ++ ) { count [ str . charAt ( i ) ] ++ ; } int max_distinct = 0 ; for ( int i = 0 ; i < NO_OF_CHARS ; i ++ ) { if ( count [ i ] != 0 ) { max_distinct ++ ; } } return max_distinct ; } static int smallesteSubstr_maxDistictChar ( String str ) { int n = str . length ( ) ; int max_distinct = max_distinct_char ( str , n ) ; int minl = n ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { String subs = null ; if ( i < j ) subs = str . substring ( i , j ) ; else subs = str . substring ( j , i ) ; int subs_lenght = subs . length ( ) ; int sub_distinct_char = max_distinct_char ( subs , subs_lenght ) ; if ( subs_lenght < minl && max_distinct == sub_distinct_char ) { minl = subs_lenght ; } } } return minl ; } static public void main ( String [ ] args ) { String str = " AABBBCBB " ; int len = smallesteSubstr_maxDistictChar ( str ) ; System . out . println ( " ▁ The ▁ length ▁ of ▁ the ▁ smallest ▁ substring " + " ▁ consisting ▁ of ▁ maximum ▁ distinct ▁ " + " characters ▁ : ▁ " + len ) ; } }

Index/key variables: NO_OF_CHARS, i
Accumulator variables: i, j, max_distinct
Iterator variables: i, j
Class/struct names: GFG
Java program:
public class Evaluate_BoolExp { static int evaluateBoolExpr ( StringBuffer s ) { int n = s . length ( ) ; for ( int i = 0 ; i < n ; i += 2 ) { if ( i + 1 < n && i + 2 < n ) { if ( s . charAt ( i + 1 ) == ' A ' ) { if ( s . charAt ( i + 2 ) == '0' || s . charAt ( i ) == 0 ) s . setCharAt ( i + 2 , '0' ) ; else s . setCharAt ( i + 2 , '1' ) ; } else if ( ( i + 1 ) < n && s . charAt ( i + 1 ) == ' B ' ) { if ( s . charAt ( i + 2 ) == '1' || s . charAt ( i ) == '1' ) s . setCharAt ( i + 2 , '1' ) ; else s . setCharAt ( i + 2 , '0' ) ; } else { if ( s . charAt ( i + 2 ) == s . charAt ( i ) ) s . setCharAt ( i + 2 , '0' ) ; else s . setCharAt ( i + 2 , '1' ) ; } } } return s . charAt ( n - 1 ) - '0' ; } public static void main ( String [ ] args ) { String s = "1C1B1B0A0" ; StringBuffer sb = new StringBuffer ( s ) ; System . out . println ( evaluateBoolExpr ( sb ) ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: Evaluate_BoolExp
Java program:
public class First_Repeated_char { static int FirstRepeated ( String str ) { int checker = 0 ; for ( int i = 0 ; i < str . length ( ) ; ++ i ) { int val = ( str . charAt ( i ) - ' a ' ) ; if ( ( checker & ( 1 << val ) ) > 0 ) return i ; checker |= ( 1 << val ) ; } return - 1 ; } public static void main ( String args [ ] ) { String s = " abcfdeacf " ; int i = FirstRepeated ( s ) ; if ( i != - 1 ) System . out . println ( " Char ▁ = ▁ " + s . charAt ( i ) + " ▁ and ▁ Index ▁ = ▁ " + i ) ; else System . out . println ( " No ▁ repeated ▁ Char " ) ; } }

Accumulator variables: checker
Iterator variables: i
Class/struct names: First_Repeated_char
Java program:
import java . util . * ; class GFG { static String alphabets = " abcdefghijklmnopqrstuvwxyz " ; static void panLipogramChecker ( char [ ] s ) { for ( int i = 0 ; i < s . length ; i ++ ) { s [ i ] = Character . toLowerCase ( s [ i ] ) ; } int counter = 0 ; for ( int i = 0 ; i < 26 ; i ++ ) { int pos = find ( s , alphabets . charAt ( i ) ) ; if ( pos < 0 pos > s . length ) counter += 1 ; } if ( counter == 0 ) System . out . println ( " Pangram " ) ; else if ( counter >= 2 ) System . out . println ( " Not ▁ a ▁ pangram ▁ but ▁ might ▁ a ▁ lipogram " ) ; else System . out . println ( " Pangrammatic ▁ Lipogram " ) ; } static int find ( char [ ] arr , char c ) { for ( int i = 0 ; i < arr . length ; i ++ ) { if ( c == arr [ i ] ) return 1 ; } return - 1 ; } public static void main ( String [ ] args ) { char [ ] str = " The ▁ quick ▁ brown ▁ fox ▁ jumped ▁ over ▁ the ▁ lazy ▁ dog " . toCharArray ( ) ; panLipogramChecker ( str ) ; str = " The ▁ quick ▁ brown ▁ fox ▁ jumps ▁ over ▁ the ▁ lazy ▁ dog " . toCharArray ( ) ; panLipogramChecker ( str ) ; str = " The ▁ quick ▁ brown ▁ fox ▁ jum ▁ over ▁ the ▁ lazy ▁ dog " . toCharArray ( ) ; panLipogramChecker ( str ) ; } }

Index/key variables: i
Accumulator variables: counter, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void nPermute ( char [ ] str , int n ) { Arrays . sort ( str ) ; int i = 1 ; do { if ( i == n ) break ; i ++ ; } while ( next_permutation ( str ) ) ; System . out . println ( String . valueOf ( str ) ) ; } static boolean next_permutation ( char [ ] p ) { for ( int a = p . length - 2 ; a >= 0 ; -- a ) if ( p [ a ] < p [ a + 1 ] ) for ( int b = p . length - 1 ; ; -- b ) if ( p [ b ] > p [ a ] ) { char t = p [ a ] ; p [ a ] = p [ b ] ; p [ b ] = t ; for ( ++ a , b = p . length - 1 ; a < b ; ++ a , -- b ) { t = p [ a ] ; p [ a ] = p [ b ] ; p [ b ] = t ; } return true ; } return false ; } public static void main ( String [ ] args ) { String str = " GEEKSFORGEEKS " ; int n = 100 ; nPermute ( str . toCharArray ( ) , n ) ; } }

Index/key variables: a, b
Accumulator variables: i
Iterator variables: a, b
Class/struct names: GFG
Java program:
class Test { static void splitString ( String str ) { StringBuffer alpha = new StringBuffer ( ) , num = new StringBuffer ( ) , special = new StringBuffer ( ) ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { if ( Character . isDigit ( str . charAt ( i ) ) ) num . append ( str . charAt ( i ) ) ; else if ( Character . isAlphabetic ( str . charAt ( i ) ) ) alpha . append ( str . charAt ( i ) ) ; else special . append ( str . charAt ( i ) ) ; } System . out . println ( alpha ) ; System . out . println ( num ) ; System . out . println ( special ) ; } public static void main ( String args [ ] ) { String str = " geeks01 $ $ for02geeks03 ! @ ! ! " ; splitString ( str ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: Test
Java program:
public class GFG { public static void SubString ( String str , int n ) { for ( int i = 0 ; i < n ; i ++ ) for ( int j = i + 1 ; j <= n ; j ++ ) System . out . println ( str . substring ( i , j ) ) ; } public static void main ( String [ ] args ) { String str = " abcd " ; SubString ( str , str . length ( ) ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { public static void printSubstrings ( String str ) { int n = str . length ( ) ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i ; j < n ; j ++ ) { for ( int k = i ; k <= j ; k ++ ) { System . out . print ( str . charAt ( k ) ) ; } System . out . println ( ) ; } } } public static void main ( String [ ] args ) { String str = " abcd " ; printSubstrings ( str ) ; } }

Accumulator variables: i, j, k
Iterator variables: i, j, k
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int n ; static int solve ( int i , int X , int Y , int a [ ] , int b [ ] , int n ) { if ( i == n ) return 0 ; if ( X <= 0 ) return b [ i ] + solve ( i + 1 , X , Y - 1 , a , b , n ) ; if ( Y <= 0 ) return a [ i ] + solve ( i + 1 , X - 1 , Y , a , b , n ) ; else return Math . max ( a [ i ] + solve ( i + 1 , X - 1 , Y , a , b , n ) , b [ i ] + solve ( i + 1 , X , Y - 1 , a , b , n ) ) ; } public static void main ( String [ ] args ) { int a [ ] = { 1 , 2 , 3 , 4 , 5 } ; int b [ ] = { 5 , 4 , 3 , 2 , 1 } ; int n = a . length ; int x = 3 , y = 3 ; System . out . println ( solve ( 0 , x , y , a , b , n ) ) ; } }

Index/key variables: i
Class/struct names: GFG
Java program:
public class GFG { static int evenNumSubstring ( String str ) { int len = str . length ( ) ; int count = 0 ; for ( int i = 0 ; i < len ; i ++ ) { int temp = str . charAt ( i ) - '0' ; if ( temp % 2 == 0 ) count += ( i + 1 ) ; } return count ; } public static void main ( String args [ ] ) { String str = "1234" ; System . out . println ( evenNumSubstring ( str ) ) ; } }

Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GfG { static class Node { Node left , right ; int val ; } static Node newNode ( int val ) { Node temp = new Node ( ) ; temp . val = val ; temp . left = null ; temp . right = null ; return temp ; } static int maxPathLenUtil ( Node root , int prev_val , int prev_len ) { if ( root == null ) return prev_len ; int cur_val = root . val ; if ( cur_val == prev_val + 1 ) { return Math . max ( maxPathLenUtil ( root . left , cur_val , prev_len + 1 ) , maxPathLenUtil ( root . right , cur_val , prev_len + 1 ) ) ; } int newPathLen = Math . max ( maxPathLenUtil ( root . left , cur_val , 1 ) , maxPathLenUtil ( root . right , cur_val , 1 ) ) ; return Math . max ( prev_len , newPathLen ) ; } static int maxConsecutivePathLength ( Node root ) { if ( root == null ) return 0 ; return maxPathLenUtil ( root , root . val - 1 , 0 ) ; } public static void main ( String [ ] args ) { Node root = newNode ( 10 ) ; root . left = newNode ( 11 ) ; root . right = newNode ( 9 ) ; root . left . left = newNode ( 13 ) ; root . left . right = newNode ( 12 ) ; root . right . left = newNode ( 13 ) ; root . right . right = newNode ( 8 ) ; System . out . println ( " Maximum ▁ Consecutive ▁ Increasing ▁ Path ▁ Length ▁ is ▁ " + maxConsecutivePathLength ( root ) ) ; } }

Class/struct names: GfG, Node
Java program:
import java . util . * ; class GFG { static boolean isSubSequence ( String str1 , String str2 ) { int m = str1 . length ( ) , n = str2 . length ( ) ; for ( int i = 0 ; i < n && j < m ; i ++ ) { if ( str1 . charAt ( j ) == str2 . charAt ( i ) ) { j ++ ; } } return ( j == m ) ; } static String findLongestString ( Vector < String > dict , String str ) { String result = " " ; int length = 0 ; for ( String word : dict ) { if ( length < word . length ( ) && isSubSequence ( word , str ) ) { result = word ; length = word . length ( ) ; } } return result ; } public static void main ( String [ ] args ) { String [ ] arr = { " ale " , " apple " , " monkey " , " plea " } ; Vector dict = new Vector ( Arrays . asList ( arr ) ) ; String str = " abpcplea " ; System . out . println ( findLongestString ( dict , str ) ) ; } }

Accumulator variables: i, j
Iterator variables: i, word
Class/struct names: GFG
Java program:
public class Suffix { static class SuffixTrieNode { static final int MAX_CHAR = 26 ; SuffixTrieNode [ ] children = new SuffixTrieNode [ MAX_CHAR ] ; { for ( int i = 0 ; i < MAX_CHAR ; i ++ ) children [ i ] = null ; } void insertSuffix ( String s ) { if ( s . length ( ) > 0 ) { char cIndex = ( char ) ( s . charAt ( 0 ) - ' a ' ) ; if ( children [ cIndex ] == null ) children [ cIndex ] = new SuffixTrieNode ( ) ; children [ cIndex ] . insertSuffix ( s . substring ( 1 ) ) ; } } } static class Suffix_trie { static final int MAX_CHAR = 26 ; SuffixTrieNode root ; Suffix_trie ( String s ) { root = new SuffixTrieNode ( ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) root . insertSuffix ( s . substring ( i ) ) ; } int _countNodesInTrie ( SuffixTrieNode node ) { if ( node == null ) return 0 ; int count = 0 ; for ( int i = 0 ; i < MAX_CHAR ; i ++ ) { if ( node . children [ i ] != null ) count += _countNodesInTrie ( node . children [ i ] ) ; } return ( 1 + count ) ; } int countNodesInTrie ( ) { return _countNodesInTrie ( root ) ; } } static int countDistinctSubstring ( String str ) { Suffix_trie sTrie = new Suffix_trie ( str ) ; return sTrie . countNodesInTrie ( ) ; } public static void main ( String args [ ] ) { String str = " ababa " ; System . out . println ( " Count ▁ of ▁ distinct ▁ substrings ▁ is ▁ " + countDistinctSubstring ( str ) ) ; } }

Index/key variables: MAX_CHAR, cIndex, i
Accumulator variables: count, i
Iterator variables: i
Class/struct names: Suffix, SuffixTrieNode, Suffix_trie
Java program:
class XOREncryption { static String encryptDecrypt ( String inputString ) { char xorKey = ' P ' ; String outputString = " " ; int len = inputString . length ( ) ; for ( int i = 0 ; i < len ; i ++ ) { outputString = outputString + Character . toString ( ( char ) ( inputString . charAt ( i ) ^ xorKey ) ) ; } System . out . println ( outputString ) ; return outputString ; } public static void main ( String [ ] args ) { String sampleString = " GeeksforGeeks " ; System . out . println ( " Encrypted ▁ String " ) ; String encryptedString = encryptDecrypt ( sampleString ) ; System . out . println ( " Decrypted ▁ String " ) ; encryptDecrypt ( encryptedString ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: XOREncryption
Java program:
import java . util . * ; class GFG { static int versionCompare ( String v1 , String v2 ) { int vnum1 = 0 , vnum2 = 0 ; for ( int i = 0 , j = 0 ; ( i < v1 . length ( ) || j < v2 . length ( ) ) ; ) { while ( i < v1 . length ( ) && v1 . charAt ( i ) != ' . ' ) { vnum1 = vnum1 * 10 + ( v1 . charAt ( i ) - '0' ) ; i ++ ; } while ( j < v2 . length ( ) && v2 . charAt ( j ) != ' . ' ) { vnum2 = vnum2 * 10 + ( v2 . charAt ( j ) - '0' ) ; j ++ ; } if ( vnum1 > vnum2 ) return 1 ; if ( vnum2 > vnum1 ) return - 1 ; vnum1 = vnum2 = 0 ; i ++ ; j ++ ; } return 0 ; } public static void main ( String [ ] args ) { String version1 = "1.0.3" ; String version2 = "1.0.7" ; if ( versionCompare ( version1 , version2 ) < 0 ) System . out . println ( version1 + " ▁ is ▁ smaller " ) ; else if ( versionCompare ( version1 , version2 ) > 0 ) System . out . println ( version2 + " ▁ is ▁ smaller " ) ; else System . out . println ( " Both ▁ version ▁ are ▁ equal " ) ; } }

Accumulator variables: i, j
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int MAX_CHAR = 256 ; public static boolean isPalindrome ( String str , int l , int h ) { while ( h > l ) if ( str . charAt ( l ++ ) != str . charAt ( h -- ) ) return false ; return true ; } public static boolean check ( String str ) { int n = str . length ( ) ; int [ ] freq = new int [ MAX_CHAR ] ; for ( int i = 0 ; i < n ; i ++ ) { freq [ str . charAt ( i ) ] ++ ; if ( freq [ str . charAt ( i ) ] > 2 ) return true ; } int k = 0 ; for ( int i = 0 ; i < n ; i ++ ) if ( freq [ str . charAt ( i ) ] > 1 ) str . replace ( str . charAt ( k ++ ) , str . charAt ( i ) ) ; str . replace ( str . charAt ( k ) , ' \0' ) ; if ( isPalindrome ( str , 0 , k - 1 ) ) { if ( ( k & 1 ) == 1 ) { if ( k / 2 >= 1 ) return ( str . charAt ( k / 2 ) == str . charAt ( k / 2 - 1 ) ) ; } return false ; } return true ; } public static void main ( String [ ] args ) { String str = " ABCABD " ; if ( check ( str ) ) System . out . println ( " Repeated ▁ Subsequence ▁ Exists " ) ; else System . out . println ( " Repeated ▁ Subsequence " + " ▁ Doesn ' t ▁ Exists " ) ; } }

Index/key variables: MAX_CHAR
Accumulator variables: h, i, k, l
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static boolean prevPermutation ( char [ ] str ) { int n = str . length - 1 ; int i = n ; while ( i > 0 && str [ i - 1 ] <= str [ i ] ) { i -- ; } if ( i <= 0 ) { return false ; } int j = i - 1 ; while ( j + 1 <= n && str [ j + 1 ] <= str [ i - 1 ] ) { j ++ ; } swap ( str , i - 1 , j ) ; StringBuilder sb = new StringBuilder ( String . valueOf ( str ) ) ; sb . reverse ( ) ; str = sb . toString ( ) . toCharArray ( ) ; return true ; } static String swap ( char [ ] ch , int i , int j ) { char temp = ch [ i ] ; ch [ i ] = ch [ j ] ; ch [ j ] = temp ; return String . valueOf ( ch ) ; } public static void main ( String [ ] args ) { char [ ] str = "4321" . toCharArray ( ) ; if ( prevPermutation ( str ) ) { System . out . println ( " Previous ▁ permutation ▁ is ▁ " + String . valueOf ( str ) ) ; } else { System . out . println ( " Previous ▁ permutation " + " doesn ' t ▁ exist " ) ; } } }

Index/key variables: i, j
Accumulator variables: i, j
Class/struct names: GFG
Java program:
class GFG { static int ans ; static class Node { int val ; Node left , right ; } ; static int length ( Node node ) { if ( node == null ) return 0 ; int left = length ( node . left ) ; int right = length ( node . right ) ; int Leftmax = 0 , Rightmax = 0 ; if ( node . left != null && node . left . val == node . val ) Leftmax += left + 1 ; if ( node . right != null && node . right . val == node . val ) Rightmax += right + 1 ; ans = Math . max ( ans , Leftmax + Rightmax ) ; return Math . max ( Leftmax , Rightmax ) ; } static int longestSameValuePath ( Node root ) { ans = 0 ; length ( root ) ; return ans ; } static Node newNode ( int data ) { Node temp = new Node ( ) ; temp . val = data ; temp . left = temp . right = null ; return temp ; } public static void main ( String [ ] args ) { Node root = null ; root = newNode ( 4 ) ; root . left = newNode ( 4 ) ; root . right = newNode ( 4 ) ; root . left . left = newNode ( 4 ) ; root . left . right = newNode ( 9 ) ; root . right . right = newNode ( 5 ) ; System . out . print ( longestSameValuePath ( root ) ) ; } }

Accumulator variables: Leftmax, Rightmax
Class/struct names: GFG, Node
Java program:
class GFG { static boolean isEditDistanceOne ( String s1 , String s2 ) { int m = s1 . length ( ) , n = s2 . length ( ) ; if ( Math . abs ( m - n ) > 1 ) return false ; int i = 0 , j = 0 ; while ( i < m && j < n ) { if ( s1 . charAt ( i ) != s2 . charAt ( j ) ) { if ( count == 1 ) return false ; if ( m > n ) i ++ ; else if ( m < n ) j ++ ; { i ++ ; j ++ ; } count ++ ; } { i ++ ; j ++ ; } } if ( i < m j < n ) count ++ ; return count == 1 ; } public static void main ( String [ ] args ) { String s1 = " gfg " ; String s2 = " gf " ; if ( isEditDistanceOne ( s1 , s2 ) ) System . out . print ( " Yes " ) ; else System . out . print ( " No " ) ; } }

Accumulator variables: count, i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static final int M = 1000 ; static int cntNum ( String X , int i , int sum , int tight , int dp [ ] [ ] [ ] ) { if ( i >= X . length ( ) sum < 0 ) { if ( sum == 0 ) { return 1 ; } return 0 ; } if ( dp [ sum ] [ i ] [ tight ] != - 1 ) { return dp [ sum ] [ i ] [ tight ] ; } int res = 0 ; int end = tight != 0 ? X . charAt ( i ) - '0' : 9 ; for ( int j = 0 ; j <= end ; j ++ ) { res += cntNum ( X , i + 1 , sum - j , ( tight > 0 & ( j == end ) ) == true ? 1 : 0 , dp ) ; } return dp [ sum ] [ i ] [ tight ] = res ; } static int UtilCntNumRange ( int L , int R , int Y ) { if ( R == 0 && Y == 0 ) { return 1 ; } String str = String . valueOf ( R ) ; int [ ] [ ] [ ] dp = new int [ M ] [ M ] [ 2 ] ; for ( int i = 0 ; i < M ; i ++ ) { for ( int j = 0 ; j < M ; j ++ ) { for ( int k = 0 ; k < 2 ; k ++ ) dp [ i ] [ j ] [ k ] = - 1 ; } } int cntR = cntNum ( str , 0 , Y , 1 , dp ) ; str = String . valueOf ( L - 1 ) ; for ( int i = 0 ; i < M ; i ++ ) { for ( int j = 0 ; j < M ; j ++ ) { for ( int k = 0 ; k < 2 ; k ++ ) dp [ i ] [ j ] [ k ] = - 1 ; } } int cntL = cntNum ( str , 0 , Y , 1 , dp ) ; return ( cntR - cntL ) ; } public static void main ( String [ ] args ) { int L = 20 , R = 10000 , Y = 14 ; System . out . print ( UtilCntNumRange ( L , R , Y ) ) ; } }

Index/key variables: M, i, j, k, sum, tight
Accumulator variables: i, j, k, res
Iterator variables: i, j, k
Class/struct names: GFG
Java program:
class GFG { static String removeSpace ( String str ) { str = str . replaceAll ( " \\ s " , " " ) ; return str ; } public static void main ( String args [ ] ) { String str = " g ▁ eeks ▁ for ▁ ge ▁ eeks ▁ " ; System . out . println ( removeSpace ( str ) ) ; } }

Class/struct names: GFG