codeparrot/xlcost-text-to-code huggingface dataset:
How to validate pin code of India using Regular Expression | Java program to validate the pin code of India using Regular Expression . ; Function to validate the pin code of India . ; Regex to check valid pin code of India . ; Compile the ReGex ; If the pin code is empty return false ; Pattern class contains matcher ( ) method to find matching between given pin code and regular expression . ; Return if the pin code matched the ReGex ; Driver Code . ; Test Case 1 : ; Test Case 2 : ; Test Case 3 : ; Test Case 4 :
import java . util . regex . * ; class GFG { public static boolean isValidPinCode ( String pinCode ) { String regex = " ^ [ 1-9 ] { 1 } [ 0-9 ] { 2 } \\ s { 0,1 } [ 0-9 ] { 3 } $ " ; Pattern p = Pattern . compile ( regex ) ; if ( pinCode == null ) { return false ; } Matcher m = p . matcher ( pinCode ) ; return m . matches ( ) ; } public static void main ( String args [ ] ) { String num1 = "132103" ; System . out . println ( num1 + " : ▁ " + isValidPinCode ( num1 ) ) ; String num2 = "201 ▁ 305" ; System . out . println ( num2 + " : ▁ " + isValidPinCode ( num2 ) ) ; String num3 = "014205" ; System . out . println ( num3 + " : ▁ " + isValidPinCode ( num3 ) ) ; String num4 = "1473598" ; System . out . println ( num4 + " : ▁ " + isValidPinCode ( num4 ) ) ; } }
How to validate time in 24 | Java program to validate the time in 24 - hour format using Regular Expression . ; Function to validate the time in 24 - hour format ; Regex to check valid time in 24 - hour format . ; Compile the ReGex ; If the time is empty return false ; Pattern class contains matcher ( ) method to find matching between given time and regular expression . ; Return if the time matched the ReGex ; Driver Code . ; Test Case 1 : ; Test Case 2 : ; Test Case 3 : ; Test Case 4 : ; Test Case 5 :
import java . util . regex . * ; class GFG { public static boolean isValidTime ( String time ) { String regex = " ( [01 ] ? [0-9 ] ▁ 2[0-3 ] ) : [ 0-5 ] [ 0-9 ] " ; Pattern p = Pattern . compile ( regex ) ; if ( time == null ) { return false ; } Matcher m = p . matcher ( time ) ; return m . matches ( ) ; } public static void main ( String args [ ] ) { String str1 = "13:05" ; System . out . println ( str1 + " : ▁ " + isValidTime ( str1 ) ) ; String str2 = "02:15" ; System . out . println ( str2 + " : ▁ " + isValidTime ( str2 ) ) ; String str3 = "24:00" ; System . out . println ( str3 + " : ▁ " + isValidTime ( str3 ) ) ; String str4 = "10:60" ; System . out . println ( str4 + " : ▁ " + isValidTime ( str4 ) ) ; String str5 = "10:15 ▁ PM " ; System . out . println ( str5 + " : ▁ " + isValidTime ( str5 ) ) ; } }
How to validate Hexadecimal Color Code using Regular Expression | Java program to validate hexadecimal colour code using Regular Expression ; Function to validate hexadecimal color code . ; Regex to check valid hexadecimal color code . ; Compile the ReGex ; If the string is empty return false ; Pattern class contains matcher ( ) method to find matching between given string and regular expression . ; Return if the string matched the ReGex ; Driver Code . ; Test Case 1 : ; Test Case 2 : ; Test Case 3 : ; Test Case 4 : ; Test Case 5 :
import java . util . regex . * ; class GFG { public static boolean isValidHexaCode ( String str ) { String regex = " ^ # ( [ A - Fa - f0-9 ] { 6 } ▁ [ A - Fa - f0-9 ] { 3 } ) $ " ; Pattern p = Pattern . compile ( regex ) ; if ( str == null ) { return false ; } Matcher m = p . matcher ( str ) ; return m . matches ( ) ; } public static void main ( String args [ ] ) { String str1 = " # 1AFFa1" ; System . out . println ( str1 + " : ▁ " + isValidHexaCode ( str1 ) ) ; String str2 = " # F00" ; System . out . println ( str2 + " : ▁ " + isValidHexaCode ( str2 ) ) ; String str3 = "123456" ; System . out . println ( str3 + " : ▁ " + isValidHexaCode ( str3 ) ) ; String str4 = " # 123abce " ; System . out . println ( str4 + " : ▁ " + isValidHexaCode ( str4 ) ) ; String str5 = " # afafah " ; System . out . println ( str5 + " : ▁ " + isValidHexaCode ( str5 ) ) ; } }
How to validate PAN Card number using Regular Expression | Java program to validate the PAN Card number using Regular Expression ; Function to validate the PAN Card number . ; Regex to check valid PAN Card number . ; Compile the ReGex ; If the PAN Card number is empty return false ; Pattern class contains matcher ( ) method to find matching between given PAN Card number using regular expression . ; Return if the PAN Card number matched the ReGex ; Driver Code . ; Test Case 1 : ; Test Case 2 : ; Test Case 3 : ; Test Case 4 : ; Test Case 5 :
import java . util . regex . * ; class GFG { public static boolean isValidPanCardNo ( String panCardNo ) { String regex = " [ A - Z ] { 5 } [ 0-9 ] { 4 } [ A - Z ] { 1 } " ; Pattern p = Pattern . compile ( regex ) ; if ( panCardNo == null ) { return false ; } Matcher m = p . matcher ( panCardNo ) ; return m . matches ( ) ; } public static void main ( String args [ ] ) { String str1 = " BNZAA2318J " ; System . out . println ( isValidPanCardNo ( str1 ) ) ; String str2 = "23ZAABN18J " ; System . out . println ( isValidPanCardNo ( str2 ) ) ; String str3 = " BNZAA2318JM " ; System . out . println ( isValidPanCardNo ( str3 ) ) ; String str4 = " BNZAA23184" ; System . out . println ( isValidPanCardNo ( str4 ) ) ; String str5 = " BNZAA ▁ 23184" ; System . out . println ( isValidPanCardNo ( str5 ) ) ; } }
How to validate time in 12 | Java program to validate the time in 12 - hour format using Regular Expression . ; Function to validate the time in 12 - hour format . ; Regex to check valid time in 12 - hour format . ; Compile the ReGex ; If the time is empty return false ; Pattern class contains matcher ( ) method to find matching between given time and regular expression . ; Return if the time matched the ReGex ; Driver Code . ; Test Case 1 : ; Test Case 2 : ; Test Case 3 : ; Test Case 4 :
import java . util . regex . * ; class GFG { public static boolean isValidTime ( String time ) { String regexPattern = " ( 1[012 ] ▁ [ 1-9 ] ) : " + " [ 0-5 ] [ 0-9 ] ( \\ s ) " + " ? ( ? i ) ( am ▁ pm ) " ; Pattern compiledPattern = Pattern . compile ( regexPattern ) ; if ( time == null ) { return false ; } Matcher m = compiledPattern . matcher ( time ) ; return m . matches ( ) ; } public static void main ( String args [ ] ) { String str1 = "12:15 ▁ AM " ; System . out . println ( isValidTime ( str1 ) ) ; String str2 = "9:45PM " ; System . out . println ( isValidTime ( str2 ) ) ; String str3 = "1:15" ; System . out . println ( isValidTime ( str3 ) ) ; String str4 = "17:30" ; System . out . println ( isValidTime ( str4 ) ) ; } }
Minimum flips in a Binary array such that XOR of consecutive subarrays of size K have different parity | Java implementation to find the minimum flips required such that alternate subarrays have different parity ; Function to find the minimum flips required in binary array ; Boolean value to indicate odd or even value of 1 's ; Loop to iterate over the subarrays of size K ; curr_index is used to iterate over all the subarrays ; Loop to iterate over the array at the jump of K to consider every parity ; Condition to check if the subarray is at even position ; The value needs to be same as the first subarray ; The value needs to be opposite of the first subarray ; Update the minimum difference ; Condition to check if the 1 s in the subarray is odd ; Driver Code
import java . util . * ; class Count_Flips { public static int count_flips ( int a [ ] , int n , int k ) { boolean set = false ; int ans = 0 , min_diff = Integer . MAX_VALUE ; for ( int i = 0 ; i < k ; i ++ ) { int curr_index = i , segment = 0 , count_zero = 0 , count_one = 0 ; while ( curr_index < n ) { if ( segment % 2 == 0 ) { if ( a [ curr_index ] == 1 ) count_zero ++ ; else count_one ++ ; } else { if ( a [ curr_index ] == 0 ) count_zero ++ ; else count_one ++ ; } curr_index = curr_index + k ; segment ++ ; } ans += Math . min ( count_one , count_zero ) ; if ( count_one < count_zero ) set = ! set ; min_diff = Math . min ( min_diff , Math . abs ( count_zero - count_one ) ) ; } if ( set ) return ans ; else return ans + min_diff ; } public static void main ( String [ ] args ) { int n = 6 , k = 3 ; int a [ ] = { 0 , 0 , 1 , 1 , 0 , 0 } ; System . out . println ( count_flips ( a , n , k ) ) ; } }
Program to build a DFA that checks if a string ends with "01" or "10" | Java Program to DFA that accepts string ending with 01 or 10. ; End position is checked using the string length value . q0 is the starting state . q1 and q2 are intermediate states . q3 and q4 are final states . ; state transitions 0 takes to q1 , 1 takes to q3 ; state transitions 0 takes to q4 , 1 takes to q2 ; state transitions 0 takes to q4 , 1 takes to q2 ; state transitions 0 takes to q1 , 1 takes to q3 ; state transitions 0 takes to q1 , 1 takes to q2 ; Driver Code ; all state transitions are printed . if string is accpetable , YES is printed . else NO is printed
class GFG { static void q1 ( String s , int i ) { System . out . print ( " q1 - > " ) ; if ( i == s . length ( ) ) { System . out . println ( " NO " ) ; return ; } if ( s . charAt ( i ) == '0' ) q1 ( s , i + 1 ) ; else q3 ( s , i + 1 ) ; } static void q2 ( String s , int i ) { System . out . print ( " q2 - > " ) ; if ( i == s . length ( ) ) { System . out . println ( " NO ▁ " ) ; return ; } if ( s . charAt ( i ) == '0' ) q4 ( s , i + 1 ) ; else q2 ( s , i + 1 ) ; } static void q3 ( String s , int i ) { System . out . print ( " q3 - > " ) ; if ( i == s . length ( ) ) { System . out . println ( " YES " ) ; return ; } if ( s . charAt ( i ) == '0' ) q4 ( s , i + 1 ) ; else q2 ( s , i + 1 ) ; } static void q4 ( String s , int i ) { System . out . print ( " q4 - > " ) ; if ( i == s . length ( ) ) { System . out . println ( " YES " ) ; return ; } if ( s . charAt ( i ) == '0' ) q1 ( s , i + 1 ) ; else q3 ( s , i + 1 ) ; } static void q0 ( String s , int i ) { System . out . print ( " q0 - > " ) ; if ( i == s . length ( ) ) { System . out . println ( " NO " ) ; return ; } if ( s . charAt ( i ) == '0' ) q1 ( s , i + 1 ) ; else q2 ( s , i + 1 ) ; } public static void main ( String [ ] args ) { String s = "010101" ; System . out . print ( " State ▁ transitions ▁ are ▁ " ) ; q0 ( s , 0 ) ; } }
Check whether two strings contain same characters in same order | package whatever do not write package name here ; if length of the b = 0 then we return true ; if length of a = 0 that means b is not present in a so we return false ; Driver code
import java . io . * ; class GFG { public static boolean checkSequence ( String a , String b ) { if ( b . length ( ) == 0 ) return true ; if ( a . length ( ) == 0 ) return false ; if ( a . charAt ( 0 ) == b . charAt ( 0 ) ) return checkSequence ( a . substring ( 1 ) , b . substring ( 1 ) ) ; else return checkSequence ( a . substring ( 1 ) , b ) ; } public static void main ( String [ ] args ) { String s1 = " Geeks " , s2 = " Geks " ; if ( checkSequence ( s1 , s2 ) ) System . out . print ( " Yes " ) ; else System . out . print ( " No " ) ; } }
String matching with * ( that matches with any ) in any of the two strings | Java program for string matching with * ; Function to check if the two strings can be matched or not ; if the string don 't have *  then character at that position  must be same. ; Driver code
import java . util . * ; public class GfG { public static int doMatch ( String A , String B ) { for ( int i = 0 ; i < A . length ( ) ; i ++ ) { if ( A . charAt ( i ) != ' * ' && B . charAt ( i ) != ' * ' ) { if ( A . charAt ( i ) != B . charAt ( i ) ) return 0 ; } } return 1 ; } public static void main ( String [ ] args ) { String A = " gee * sforgeeks " ; String B = " geeksforgeeks " ; System . out . println ( doMatch ( A , B ) ) ; } }
Number of substrings of one string present in other | Java program to count number of substrings of s1 present in s2 . ; s3 stores all substrings of s1 ; check the presence of s3 in s2 ; Driver code
import java . util . * ; class GFG { static int countSubstrs ( String s1 , String s2 ) { int ans = 0 ; for ( int i = 0 ; i < s1 . length ( ) ; i ++ ) { String s3 = " " ; char [ ] s4 = s1 . toCharArray ( ) ; for ( int j = i ; j < s1 . length ( ) ; j ++ ) { s3 += s4 [ j ] ; if ( s2 . indexOf ( s3 ) != - 1 ) ans ++ ; } } return ans ; } public static void main ( String [ ] args ) { String s1 = " aab " , s2 = " aaaab " ; System . out . println ( countSubstrs ( s1 , s2 ) ) ; } }
Find Nth term of series 1 , 4 , 15 , 72 , 420. . . | Java program to find N - th term of the series : 1 , 4 , 15 , 72 , 420 ; Function to find factorial of N ; return factorial of N ; calculate Nth term of series ; Driver Code
import java . util . * ; import java . lang . * ; import java . io . * ; class GFG { static int factorial ( int N ) { int fact = 1 ; for ( int i = 1 ; i <= N ; i ++ ) fact = fact * i ; return fact ; } static int nthTerm ( int N ) { return ( factorial ( N ) * ( N + 2 ) / 2 ) ; } public static void main ( String args [ ] ) { int N = 6 ; System . out . println ( nthTerm ( N ) ) ; } }
Sum of nodes at maximum depth of a Binary Tree | Java code to find the sum of the nodes which are present at the maximum depth . ; Function to return a new node ; Function to find the sum of the node which are present at the maximum depth . While traversing the nodes compare the level of the node with max_level ( Maximum level till the current node ) . If the current level exceeds the maximum level , update the max_level as current level . If the max level and current level are same , add the root data to current sum . ; Driver Code
class GFG { static int sum = 0 , max_level = Integer . MIN_VALUE ; static class Node { int d ; Node l ; Node r ; } ; static Node createNode ( int d ) { Node node ; node = new Node ( ) ; node . d = d ; node . l = null ; node . r = null ; return node ; } static void sumOfNodesAtMaxDepth ( Node ro , int level ) { if ( ro == null ) return ; if ( level > max_level ) { sum = ro . d ; max_level = level ; } else if ( level == max_level ) { sum = sum + ro . d ; } sumOfNodesAtMaxDepth ( ro . l , level + 1 ) ; sumOfNodesAtMaxDepth ( ro . r , level + 1 ) ; } public static void main ( String [ ] args ) { Node root ; root = createNode ( 1 ) ; root . l = createNode ( 2 ) ; root . r = createNode ( 3 ) ; root . l . l = createNode ( 4 ) ; root . l . r = createNode ( 5 ) ; root . r . l = createNode ( 6 ) ; root . r . r = createNode ( 7 ) ; sumOfNodesAtMaxDepth ( root , 0 ) ; System . out . println ( sum ) ; } }
Match Expression where a single special character in pattern can match one or more characters | Java program for pattern matching where a single special character can match one more characters ; Returns true if pat matches with text . ; i is used as an index in pattern and j as an index in text . ; Traverse through pattern ; If current character of pattern is not ' # ' ; If does not match with text . ; If matches , increment i and j ; Current character is ' # ' ; At least one character must match with # ; Match characters with # until a matching character is found . ; Matching with # is over , move ahead in pattern ; Driver code
import java . util . * ; import java . lang . * ; import java . io . * ; class GFG { public static boolean regexMatch ( String text , String pat ) { int lenText = text . length ( ) ; int lenPat = pat . length ( ) ; char [ ] Text = text . toCharArray ( ) ; char [ ] Pat = pat . toCharArray ( ) ; int i = 0 , j = 0 ; while ( i < lenPat ) { if ( Pat [ i ] != ' # ' ) { if ( Pat [ i ] != Text [ j ] ) return false ; i ++ ; j ++ ; } else { j ++ ; while ( Text [ j ] != Pat [ i + 1 ] ) j ++ ; i ++ ; } } return ( j == lenText ) ; } public static void main ( String [ ] args ) { String str = " ABABABA " ; String pat = " A # B # A " ; if ( regexMatch ( str , pat ) ) System . out . println ( " yes " ) ; else System . out . println ( " no " ) ; } }
Replace all occurrences of string AB with C without using extra space | Efficient Java program to replace all occurrences of " AB " with " C " ; Index in modified string ; Index in original string ; Traverse string ; Replace occurrence of " AB " with " C " ; Increment j by 2 ; add a null character to terminate string ; Driver code
import java . io . * ; class GFG { static void translate ( char str [ ] ) { int len = str . length ; if ( len < 2 ) return ; int i = 0 ; int j = 0 ; while ( j < len - 1 ) { if ( str [ j ] == ' A ' && str [ j + 1 ] == ' B ' ) { j = j + 2 ; str [ i ++ ] = ' C ' ; continue ; } str [ i ++ ] = str [ j ++ ] ; } if ( j == len - 1 ) str [ i ++ ] = str [ j ] ; str [ i ] = ' ▁ ' ; str [ len - 1 ] = ' ▁ ' ; } public static void main ( String args [ ] ) { String st = " helloABworldABGfG " ; char str [ ] = st . toCharArray ( ) ; translate ( str ) ; System . out . println ( " The ▁ modified ▁ string ▁ is ▁ : " ) ; System . out . println ( str ) ; } }
Search a Word in a 2D Grid of characters | Java program to search a word in a 2D grid ; Rows and columns in the given grid ; For searching in all 8 direction ; This function searches in all 8 - direction from point ( row , col ) in grid [ ] [ ] ; If first character of word doesn 't match with  given starting point in grid. ; Search word in all 8 directions starting from ( row , col ) ; Initialize starting point for current direction ; First character is already checked , match remaining characters ; If out of bound break ; If not matched , break ; Moving in particular direction ; If all character matched , then value of must be equal to length of word ; Searches given word in a given matrix in all 8 directions ; Consider every point as starting point and search given word ; Driver code
import java . io . * ; import java . util . * ; class GFG { static int R , C ; static int [ ] x = { - 1 , - 1 , - 1 , 0 , 0 , 1 , 1 , 1 } ; static int [ ] y = { - 1 , 0 , 1 , - 1 , 1 , - 1 , 0 , 1 } ; static boolean search2D ( char [ ] [ ] grid , int row , int col , String word ) { if ( grid [ row ] [ col ] != word . charAt ( 0 ) ) return false ; int len = word . length ( ) ; for ( int dir = 0 ; dir < 8 ; dir ++ ) { int k , rd = row + x [ dir ] , cd = col + y [ dir ] ; for ( k = 1 ; k < len ; k ++ ) { if ( rd >= R rd < 0 cd >= C cd < 0 ) break ; if ( grid [ rd ] [ cd ] != word . charAt ( k ) ) break ; rd += x [ dir ] ; cd += y [ dir ] ; } if ( k == len ) return true ; } return false ; } static void patternSearch ( char [ ] [ ] grid , String word ) { for ( int row = 0 ; row < R ; row ++ ) { for ( int col = 0 ; col < C ; col ++ ) { if ( search2D ( grid , row , col , word ) ) System . out . println ( " pattern ▁ found ▁ at ▁ " + row + " , ▁ " + col ) ; } } } public static void main ( String args [ ] ) { R = 3 ; C = 13 ; char [ ] [ ] grid = { { ' G ' , ' E ' , ' E ' , ' K ' , ' S ' , ' F ' , ' O ' , ' R ' , ' G ' , ' E ' , ' E ' , ' K ' , ' S ' } , { ' G ' , ' E ' , ' E ' , ' K ' , ' S ' , ' Q ' , ' U ' , ' I ' , ' Z ' , ' G ' , ' E ' , ' E ' , ' K ' } , { ' I ' , ' D ' , ' E ' , ' Q ' , ' A ' , ' P ' , ' R ' , ' A ' , ' C ' , ' T ' , ' I ' , ' C ' , ' E ' } } ; patternSearch ( grid , " GEEKS " ) ; System . out . println ( ) ; patternSearch ( grid , " EEE " ) ; } }
Boyer Moore Algorithm for Pattern Searching | Java Program for Bad Character Heuristic of Boyer Moore String Matching Algorithm ; A utility function to get maximum of two integers ; The preprocessing function for Boyer Moore 's  bad character heuristic ; Initialize all occurrences as - 1 ; Fill the actual value of last occurrence of a character ( indices of table are ascii and values are index of occurence ) ; A pattern searching function that uses Bad Character Heuristic of Boyer Moore Algorithm ; Fill the bad character array by calling the preprocessing function badCharHeuristic ( ) for given pattern ; s is shift of the pattern with respect to text there are n - m + 1 potential allignments ; Keep reducing index j of pattern while characters of pattern and text are matching at this shift s ; If the pattern is present at current shift , then index j will become - 1 after the above loop ; Shift the pattern so that the next character in text aligns with the last occurrence of it in pattern . The condition s + m < n is necessary for the case when pattern occurs at the end of text ; Shift the pattern so that the bad character in text aligns with the last occurrence of it in pattern . The max function is used to make sure that we get a positive shift . We may get a negative shift if the last occurrence of bad character in pattern is on the right side of the current character . ; Driver program to test above function
class AWQ { static int NO_OF_CHARS = 256 ; static int max ( int a , int b ) { return ( a > b ) ? a : b ; } static void badCharHeuristic ( char [ ] str , int size , int badchar [ ] ) { for ( int i = 0 ; i < NO_OF_CHARS ; i ++ ) badchar [ i ] = - 1 ; for ( int i = 0 ; i < size ; i ++ ) badchar [ ( int ) str [ i ] ] = i ; } static void search ( char txt [ ] , char pat [ ] ) { int m = pat . length ; int n = txt . length ; int badchar [ ] = new int [ NO_OF_CHARS ] ; badCharHeuristic ( pat , m , badchar ) ; int s = 0 ; while ( s <= ( n - m ) ) { int j = m - 1 ; while ( j >= 0 && pat [ j ] == txt [ s + j ] ) j -- ; if ( j < 0 ) { System . out . println ( " Patterns ▁ occur ▁ at ▁ shift ▁ = ▁ " + s ) ; s += ( s + m < n ) ? m - badchar [ txt [ s + m ] ] : 1 ; } else s += max ( 1 , j - badchar [ txt [ s + j ] ] ) ; } } public static void main ( String [ ] args ) { char txt [ ] = " ABAAABCD " . toCharArray ( ) ; char pat [ ] = " ABC " . toCharArray ( ) ; search ( txt , pat ) ; } }
Sum of nodes at maximum depth of a Binary Tree | Java code for sum of nodes at maximum depth ; Constructor ; function to find the sum of nodes at maximum depth arguments are node and max , where max is to match the depth of node at every call to node , if max will be equal to 1 , means we are at deepest node . ; base case ; max == 1 to track the node at deepest level ; recursive call to left and right nodes ; maxDepth function to find the max depth of the tree ; base case ; either leftDepth of rightDepth is greater add 1 to include height of node at which call is ; call to function to calculate max depth ; Driver code ; Constructing tree ; call to calculate required sum
import java . util . * ; class Node { int data ; Node left , right ; public Node ( int data ) { this . data = data ; this . left = null ; this . right = null ; } } class GfG { public static int sumMaxLevelRec ( Node node , int max ) { if ( node == null ) return 0 ; if ( max == 1 ) return node . data ; return sumMaxLevelRec ( node . left , max - 1 ) + sumMaxLevelRec ( node . right , max - 1 ) ; } public static int maxDepth ( Node node ) { if ( node == null ) return 0 ; return 1 + Math . max ( maxDepth ( node . left ) , maxDepth ( node . right ) ) ; } public static int sumMaxLevel ( Node root ) { int MaxDepth = maxDepth ( root ) ; return sumMaxLevelRec ( root , MaxDepth ) ; } public static void main ( String [ ] args ) { Node root = new Node ( 1 ) ; root . left = new Node ( 2 ) ; root . right = new Node ( 3 ) ; root . left . left = new Node ( 4 ) ; root . left . right = new Node ( 5 ) ; root . right . left = new Node ( 6 ) ; root . right . right = new Node ( 7 ) ; System . out . println ( sumMaxLevel ( root ) ) ; } }