codeparrot/xlcost-text-to-code huggingface dataset:
Check if a given string is Even | Java program implementation of the approach ; Function to check if the string str is palindromic or not ; Pointers to iterate the string from both ends ; If characters are found to be distinct ; Return true if the string is palindromic ; Function to generate string from characters at odd indices ; Function to generate string from characters at even indices ; Functions to checks if string is Even - Odd Palindrome or not ; Generate odd indexed string ; Generate even indexed string ; Check for Palindrome ; Driver code
import java . util . * ; import java . io . * ; class GFG { static boolean isPalindrome ( String str ) { int l = 0 ; int h = str . length ( ) - 1 ; while ( h > l ) { if ( str . charAt ( l ++ ) != str . charAt ( h -- ) ) return false ; } return true ; } static String makeOddString ( String str ) { String odd = " " ; for ( int i = 1 ; i < str . length ( ) ; i += 2 ) { odd += str . charAt ( i ) ; } return odd ; } static String makeevenString ( String str ) { String even = " " ; for ( int i = 0 ; i < str . length ( ) ; i += 2 ) { even += str . charAt ( i ) ; } return even ; } static void checkevenOddPalindrome ( String str ) { String odd = makeOddString ( str ) ; String even = makeevenString ( str ) ; if ( isPalindrome ( odd ) && isPalindrome ( even ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } public static void main ( String [ ] args ) { String str = " abzzab " ; checkevenOddPalindrome ( str ) ; } }
Check given string is oddly palindrome or not | Java program for the above approach ; Function to check if the String str is palindromic or not ; Iterate the String str from left and right pointers ; Keep comparing characters while they are same ; If they are not same then return false ; Return true if the String is palindromic ; Function to make String using odd indices of String str ; Functions checks if characters at odd index of the String forms palindrome or not ; Make odd indexed String ; Check for Palindrome ; Driver Code ; Given String ; Function Call
class GFG { public static boolean isPalindrome ( String str ) { int l = 0 ; int h = str . length ( ) - 1 ; while ( h > l ) { if ( str . charAt ( l ) != str . charAt ( h ) ) { return false ; } l ++ ; h -- ; } return true ; } public static String makeOddString ( String str ) { String odd = " " ; for ( int i = 1 ; i < str . length ( ) ; i += 2 ) { odd += str . charAt ( i ) ; } return odd ; } public static void checkOddlyPalindrome ( String str ) { String odd = makeOddString ( str ) ; if ( isPalindrome ( odd ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } public static void main ( String [ ] args ) { String str = " ddwfefwde " ; checkOddlyPalindrome ( str ) ; } }
Count of binary strings of given length consisting of at least one 1 | Java program to implement the above approach ; Function to return the count of Strings ; Calculate Math . pow ( 2 , n ) ; Return Math . pow ( 2 , n ) - 1 ; Driver Code
import java . util . * ; class GFG { static long count_Strings ( long n ) { int x = 1 ; for ( int i = 1 ; i < n ; i ++ ) { x = ( 1 << x ) ; } return x - 1 ; } public static void main ( String [ ] args ) { long n = 3 ; System . out . print ( count_Strings ( n ) ) ; } }
String formed with middle character of every right substring followed by left sequentially | Java implementation of the above approach ; Function to decrypt and print the new String ; If the whole String has been traversed ; To calculate middle index of the String ; Print the character at middle index ; Recursively call for right - subString ; Recursive call for left - subString ; Driver Code
class GFG { static void decrypt ( String Str , int Start , int End ) { if ( Start > End ) { return ; } int mid = ( Start + End ) >> 1 ; System . out . print ( Str . charAt ( mid ) ) ; decrypt ( Str , mid + 1 , End ) ; decrypt ( Str , Start , mid - 1 ) ; } public static void main ( String [ ] args ) { int N = 4 ; String Str = " abcd " ; decrypt ( Str , 0 , N - 1 ) ; System . out . print ( "NEW_LINE"); N = 6 ; Str = " gyuitp " ; decrypt ( Str , 0 , N - 1 ) ; } }
Check whether the binary equivalent of a number ends with given string or not | Java implementation of the above approach ; Function returns true if s1 is suffix of s2 ; Function to check if binary equivalent of a number ends in "111" or not ; To store the binary number ; Count used to store exponent value ; Driver code
class GFG { static boolean isSuffix ( String s1 , String s2 ) { int n1 = s1 . length ( ) , n2 = s2 . length ( ) ; if ( n1 > n2 ) return false ; for ( int i = 0 ; i < n1 ; i ++ ) if ( s1 . charAt ( n1 - i - 1 ) != s2 . charAt ( n2 - i - 1 ) ) return false ; return true ; } static boolean CheckBinaryEquivalent ( int N , String str ) { int B_Number = 0 ; int cnt = 0 ; while ( N != 0 ) { int rem = N % 2 ; int c = ( int ) Math . pow ( 10 , cnt ) ; B_Number += rem * c ; N /= 2 ; cnt ++ ; } String bin = Integer . toString ( B_Number ) ; return isSuffix ( str , bin ) ; } public static void main ( String [ ] args ) { int N = 23 ; String str = "111" ; if ( CheckBinaryEquivalent ( N , str ) ) System . out . print ( "YesNEW_LINE"); else System . out . print ( "NoNEW_LINE"); } }
Count of substrings consisting only of vowels | Java program to count all subStrings in a String which contains only vowels ; Function to check if a character is vowel or not ; Function to check whether String contains only vowel ; Check if the character is not vowel then invalid ; Function to Count all subStrings in a String which contains only vowels ; Generate all subString of s ; If temp contains only vowels ; Increment the count ; Driver code
import java . util . * ; class GFG { static boolean isvowel ( char ch ) { return ( ch == ' a ' ch == ' e ' ch == ' i ' ch == ' o ' ch == ' u ' ) ; } static boolean isvalid ( String s ) { int n = s . length ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( ! isvowel ( s . charAt ( i ) ) ) return false ; } return true ; } static int CountTotal ( String s ) { int ans = 0 ; int n = s . length ( ) ; for ( int i = 0 ; i < n ; i ++ ) { String temp = " " ; for ( int j = i ; j < n ; j ++ ) { temp += s . charAt ( j ) ; if ( isvalid ( temp ) ) ans += 1 ; } } return ans ; } public static void main ( String [ ] args ) { String s = " aeoibsddaaeiouudb " ; System . out . print ( ( CountTotal ( s ) ) + "NEW_LINE"); } }
Longest substring of vowels with no two adjacent alphabets same | Java implementation of the above approach ; Function to check a character is vowel or not ; Function to check a subString is valid or not ; If size is 1 then check only first character ; If 0 'th character is  not vowel then invalidlen ; If two adjacent characters are same or i 'th char is  not vowel then invalid ; Function to find length of longest subString consisting only of vowels and no similar adjacent alphabets ; Stores max length of valid subString ; For current subString ; Check if subString is valid ; Size of subString is ( j - i + 1 ) ; Driver code
import java . io . * ; class GFG { static boolean isVowel ( char c ) { return ( c == ' a ' c == ' e ' c == ' i ' c == ' o ' c == ' u ' ) ; } static boolean isValid ( String s ) { int n = s . length ( ) ; if ( n == 1 ) return ( isVowel ( s . charAt ( 0 ) ) ) ; if ( isVowel ( s . charAt ( 0 ) ) == false ) return false ; for ( int i = 1 ; i < n ; i ++ ) { if ( s . charAt ( i ) == s . charAt ( i - 1 ) || ! isVowel ( s . charAt ( i ) ) ) return false ; } return true ; } static int findMaxLen ( String s ) { int maxLen = 0 ; int n = s . length ( ) ; for ( int i = 0 ; i < n ; i ++ ) { String temp = " " ; for ( int j = i ; j < n ; j ++ ) { temp = temp + s . charAt ( j ) ; if ( isValid ( temp ) ) maxLen = Math . max ( maxLen , ( j - i + 1 ) ) ; } } return maxLen ; } public static void main ( String [ ] args ) { String Str = " aeoibsddaeiouudb " ; System . out . println ( findMaxLen ( Str ) ) ; } }
Check if the number is balanced | Java program to check if a number is Balanced or not ; Function to check whether N is Balanced Number or not ; Calculating the Leftsum and rightSum simultaneously ; Typecasting each character to integer and adding the digit to respective sums ; Driver Code ; Function call
import java . io . * ; class GFG { private static void BalancedNumber ( String s ) { int Leftsum = 0 ; int Rightsum = 0 ; for ( int i = 0 ; i < s . length ( ) / 2 ; i ++ ) { Leftsum += ( int ) ( s . charAt ( i ) - '0' ) ; Rightsum += ( int ) ( s . charAt ( s . length ( ) - 1 - i ) - '0' ) ; } if ( Leftsum == Rightsum ) System . out . println ( " Balanced " ) ; else System . out . println ( " Not ▁ Balanced " ) ; } public static void main ( String [ ] args ) { String s = "12321" ; BalancedNumber ( s ) ; } }
Count of N size strings consisting of at least one vowel and one consonant | Java program to count all possible Strings of length N consisting of atleast one vowel and one consonant ; Function to return base ^ exponent ; Function to count all possible Strings ; All possible Strings of length N ; Vowels only ; Consonants only ; Return the final result ; Driver code
class GFG { static int mod = ( int ) ( 1e9 + 7 ) ; static int expo ( int base , int exponent ) { int ans = 1 ; while ( exponent != 0 ) { if ( ( exponent & 1 ) == 1 ) { ans = ans * base ; ans = ans % mod ; } base = base * base ; base %= mod ; exponent >>= 1 ; } return ans % mod ; } static int findCount ( int N ) { int ans = ( expo ( 26 , N ) - expo ( 5 , N ) - expo ( 21 , N ) ) % mod ; ans += mod ; ans %= mod ; return ans ; } public static void main ( String [ ] args ) { int N = 3 ; System . out . print ( findCount ( N ) ) ; } }
Sum of decomposition values of all suffixes of an Array | Java implementation to find the sum of Decomposition values of all suffixes of an array ; Function to find the decomposition values of the array ; Stack ; Variable to maintain min value in stack ; Loop to iterate over the array ; Condition to check if the stack is empty ; Condition to check if the top of the stack is greater than the current element ; Loop to pop the element out ; The size of the stack is the max no of subarrays for suffix till index i from the right ; Driver Code
import java . util . * ; class GFG { static int decompose ( Vector < Integer > S ) { Stack < Integer > s = new Stack < Integer > ( ) ; int N = S . size ( ) ; int ans = 0 ; int nix = Integer . MAX_VALUE ; for ( int i = N - 1 ; i >= 0 ; i -- ) { if ( s . isEmpty ( ) ) { s . add ( S . get ( i ) ) ; nix = S . get ( i ) ; } else { if ( S . get ( i ) < s . peek ( ) ) { s . add ( S . get ( i ) ) ; nix = Math . min ( nix , S . get ( i ) ) ; } else { int val = S . get ( i ) ; while ( ! s . isEmpty ( ) && val >= s . peek ( ) ) { s . pop ( ) ; } nix = Math . min ( nix , S . get ( i ) ) ; s . add ( nix ) ; } } ans += s . size ( ) ; } return ans ; } public static void main ( String args [ ] ) { Vector < Integer > S = new Vector < Integer > ( ) ; S . add ( 9 ) ; S . add ( 6 ) ; S . add ( 9 ) ; S . add ( 35 ) ; System . out . println ( decompose ( S ) ) ; } }
Maximum number of set bits count in a K | Java program to find the maximum set bits in a substring of size K ; Function that find Maximum number of set bit appears in a substring of size K . ; Traverse string 1 to k ; Increment count if character is set bit ; Traverse string k + 1 to length of string ; remove the contribution of the ( i - k ) th character which is no longer in the window ; add the contribution of the current character ; update maxCount at for each window of size k ; return maxCount ; Driver Program
import java . util . * ; class GFG { static int maxSetBitCount ( String s , int k ) { int maxCount = 0 , n = s . length ( ) ; int count = 0 ; for ( int i = 0 ; i < k ; i ++ ) { if ( s . charAt ( i ) == '1' ) count ++ ; } maxCount = count ; for ( int i = k ; i < n ; i ++ ) { if ( s . charAt ( i - k ) == '1' ) count -- ; if ( s . charAt ( i ) == '1' ) count ++ ; maxCount = Math . max ( maxCount , count ) ; } return maxCount ; } public static void main ( String [ ] args ) { String s = "100111010" ; int k = 3 ; System . out . println ( maxSetBitCount ( s , k ) ) ; } }
Minimum characters to be deleted from the beginning of two strings to make them equal | Java Program to count minimum number of characters to be deleted from the beginning of the two strings to make the strings equal ; Function that finds minimum character required to be deleted ; Iterate in the strings ; Check if the characters are not equal ; Return the result ; Driver Code
import java . util . * ; class GFG { static int minDel ( String s1 , String s2 ) { int i = s1 . length ( ) ; int j = s2 . length ( ) ; while ( i > 0 && j > 0 ) { if ( s1 . charAt ( i - 1 ) != s2 . charAt ( j - 1 ) ) { break ; } i -- ; j -- ; } return i + j ; } public static void main ( String args [ ] ) { String s1 = " geeksforgeeks " , s2 = " peeks " ; System . out . print ( minDel ( s1 , s2 ) ) ; } }
Minimum characters to be deleted from the end to make given two strings equal | Java program to count minimum number of characters to be deleted to make the strings equal ; Function that finds minimum character required to be deleted ; Iterate in the strings ; Check if the characters are not equal ; Return the result ; Driver code
class GFG { static int minDel ( String s1 , String s2 ) { int i = 0 ; while ( i < Math . min ( s1 . length ( ) , s2 . length ( ) ) ) { if ( s1 . charAt ( i ) != s2 . charAt ( i ) ) { break ; } i ++ ; } int ans = ( ( s1 . length ( ) - i ) + ( s2 . length ( ) - i ) ) ; return ans ; } public static void main ( String [ ] args ) { String s1 = " geeks " ; String s2 = " geeksfor " ; System . out . println ( minDel ( s1 , s2 ) ) ; } }
Count of triplets from the given string with non | Java program to count of triplets from the given string with non - equidistant characters ; Function to count valid triplets ; Store frequencies of a , b and c ; If the current letter is ' a ' ; If the current letter is ' b ' ; If the current letter is ' c ' ; Calculate total no of triplets ; Subtract invalid triplets ; Driver code
import java . util . * ; class GFG { static void CountValidTriplet ( String s , int n ) { int count_a = 0 , count_b = 0 , count_c = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( s . charAt ( i ) == ' a ' ) count_a ++ ; if ( s . charAt ( i ) == ' b ' ) count_b ++ ; if ( s . charAt ( i ) == ' c ' ) count_c ++ ; } int Total_triplet = count_a * count_b * count_c ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { if ( ( 2 * j - i ) < n && s . charAt ( j ) != s . charAt ( i ) && s . charAt ( j * 2 - i ) != s . charAt ( j ) && s . charAt ( 2 * j - i ) != s . charAt ( i ) ) Total_triplet -- ; } } System . out . println ( Total_triplet ) ; } public static void main ( String [ ] args ) { String s = " abcbcabc " ; int n = s . length ( ) ; CountValidTriplet ( s , n ) ; } }
Check if given Parentheses expression is balanced or not | Java program for the above approach . ; Function to check if parentheses are balanced ; Initialising variables ; Traversing the expression ; It is a closing parenthesis ; This means there are more Closing parenthesis than opening ones ; If count is not zero , It means there are more opening parenthesis ; Driver code
class GFG { public static boolean isBalanced ( String exp ) { boolean flag = true ; int count = 0 ; for ( int i = 0 ; i < exp . length ( ) ; i ++ ) { if ( exp . charAt ( i ) == ' ( ' ) { count ++ ; } else { count -- ; } if ( count < 0 ) { flag = false ; break ; } } if ( count != 0 ) { flag = false ; } return flag ; } public static void main ( String [ ] args ) { String exp1 = " ( ( ( ) ) ) ( ) ( ) " ; if ( isBalanced ( exp1 ) ) System . out . println ( " Balanced " ) ; else System . out . println ( " Not ▁ Balanced " ) ; String exp2 = " ( ) ) ( ( ( ) ) " ; if ( isBalanced ( exp2 ) ) System . out . println ( " Balanced " ) ; else System . out . println ( " Not ▁ Balanced " ) ; } }
Longest Palindromic Subsequence of two distinct characters | Java implementation to find Longest Palindromic Subsequence consisting of two distinct characters only ; Function that prints the length of maximum required subsequence ; Calculate length of String ; Store number of occurrences of each character and position of each chatacter in String ; Iterate all characters ; Calculate number of occurences of the current character ; Iterate half of the number of positions of current character ; Determine maximum length of a character between l and r position ; Compute the maximum from all ; Printing maximum length ; Driver Code
import java . util . * ; class GFG { static void longestPalindrome ( String s ) { int n = s . length ( ) ; int [ ] [ ] pref = new int [ 26 ] [ n ] ; Vector < Integer > [ ] pos = new Vector [ 26 ] ; for ( int i = 0 ; i < pos . length ; i ++ ) pos [ i ] = new Vector < Integer > ( ) ; pref [ s . charAt ( 0 ) - ' a ' ] [ 0 ] ++ ; pos [ s . charAt ( 0 ) - ' a ' ] . add ( 0 ) ; for ( int i = 1 ; i < n ; i ++ ) { for ( int j = 0 ; j < 26 ; j ++ ) pref [ j ] [ i ] += pref [ j ] [ i - 1 ] ; int index = s . charAt ( i ) - ' a ' ; pref [ index ] [ i ] ++ ; pos [ index ] . add ( i ) ; } int ans = 0 ; for ( int i = 0 ; i < 26 ; i ++ ) { int size = pos [ i ] . size ( ) ; ans = Math . max ( ans , size ) ; for ( int j = 0 ; j < size / 2 ; j ++ ) { int l = pos [ i ] . elementAt ( j ) ; int r = pos [ i ] . elementAt ( size - j - 1 ) - 1 ; for ( int k = 0 ; k < 26 ; k ++ ) { int sum = pref [ k ] [ r ] - pref [ k ] [ l ] ; ans = Math . max ( ans , 2 * ( j + 1 ) + sum ) ; } } } System . out . print ( ans + "NEW_LINE"); } public static void main ( String [ ] args ) { String S = " bbccdcbb " ; longestPalindrome ( S ) ; } }
Check if a given string can be formed using characters of adjacent cells of a Matrix | Java Program to check if a given word can be formed from the adjacent characters in a matrix of characters ; Function to check if the word exists ; If index exceeds board range ; If the current cell does not contain the required character ; If the cell contains the required character and is the last character of the word required to be matched ; Return true as word is found ; Mark cell visited ; Check Adjacent cells for the next character ; Restore cell value ; Driver Code
import java . util . * ; class GFG { static boolean checkWord ( char [ ] [ ] board , String word , int index , int row , int col ) { if ( row < 0 col < 0 row >= board . length col >= board [ 0 ] . length ) return false ; if ( board [ row ] [ col ] != word . charAt ( index ) ) return false ; else if ( index == word . length ( ) - 1 ) return true ; char temp = board [ row ] [ col ] ; board [ row ] [ col ] = ' * ' ; if ( checkWord ( board , word , index + 1 , row + 1 , col ) || checkWord ( board , word , index + 1 , row - 1 , col ) || checkWord ( board , word , index + 1 , row , col + 1 ) || checkWord ( board , word , index + 1 , row , col - 1 ) ) { board [ row ] [ col ] = temp ; return true ; } board [ row ] [ col ] = temp ; return false ; } public static void main ( String [ ] args ) { char [ ] [ ] board = { { ' A ' , ' B ' , ' C ' , ' E ' } , { ' S ' , ' F ' , ' C ' , ' S ' } , { ' A ' , ' D ' , ' E ' , ' E ' } } ; String word = " CFDASABCESEE " ; for ( int i = 0 ; i < board . length ; i ++ ) { for ( int j = 0 ; j < board [ 0 ] . length ; j ++ ) { if ( board [ i ] [ j ] == word . charAt ( 0 ) && checkWord ( board , word , 0 , i , j ) ) { System . out . println ( " True " ) ; return ; } } } System . out . println ( " False " ) ; } }
Split the number N by maximizing the count of subparts divisible by K | Java program to split the number N by maximizing the count of subparts divisible by K ; Function to count the subparts ; Total subStr till now ; If it can be divided , then this subString is one of the possible answer ; Convert String to long and check if its divisible with X ; Consider there is no vertical cut between this index and the next one , hence take total carrying total substr a . ; If there is vertical cut between this index and next one , then we start again with subStr as " " and add b for the count of subStr upto now ; Return max of both the cases ; Driver code
class GFG { static int count ( String N , int X , String subStr , int index , int n ) { if ( index == n ) return 0 ; String a = subStr + N . charAt ( index ) ; int b = 0 ; if ( Long . valueOf ( a ) % X == 0 ) b = 1 ; int m1 = count ( N , X , a , index + 1 , n ) ; int m2 = b + count ( N , X , " " , index + 1 , n ) ; return Math . max ( m1 , m2 ) ; } public static void main ( String [ ] args ) { String N = "00001242" ; int K = 3 ; int l = N . length ( ) ; System . out . print ( count ( N , K , " " , 0 , l ) + "NEW_LINE"); } }
Check if a number ends with another number or not | Java program for the above approach ; Function to check if B is a suffix of A or not ; Convert numbers into strings ; Find the lengths of strings s1 and s2 ; Base case ; Traverse the strings s1 & s2 ; If at any index characters are unequals then return false ; Return true ; Driver code ; Given numbers ; Function Call ; If B is a suffix of A , then print " Yes "
class GFG { public static boolean checkSuffix ( int A , int B ) { String s1 = String . valueOf ( A ) ; String s2 = String . valueOf ( B ) ; int n1 = s1 . length ( ) ; int n2 = s2 . length ( ) ; if ( n1 < n2 ) { return false ; } for ( int i = 0 ; i < n2 ; i ++ ) { if ( s1 . charAt ( n1 - i - 1 ) != s2 . charAt ( n2 - i - 1 ) ) { return false ; } } return true ; } public static void main ( String [ ] args ) { int A = 12345 , B = 45 ; boolean result = checkSuffix ( A , B ) ; if ( result ) { System . out . print ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } }
Check if a number ends with another number or not | Java program for the above approach ; Function to check if B is a suffix of A or not ; Convert numbers into Strings ; Check if s2 is a suffix of s1 or not ; If result is true , print " Yes " ; Driver Code ; Given numbers ; Function Call
import java . util . * ; class GFG { static void checkSuffix ( int A , int B ) { String s1 = String . valueOf ( A ) ; String s2 = String . valueOf ( B ) ; boolean result ; result = s1 . endsWith ( s2 ) ; if ( result ) { System . out . print ( " Yes " ) ; } else { System . out . print ( " No " ) ; } } public static void main ( String [ ] args ) { int A = 12345 , B = 45 ; checkSuffix ( A , B ) ; } }
Binary string with given frequencies of sums of consecutive pairs of characters | Java program to generate a binary String with given frequencies of sums of consecutive pair of characters ; A Function that generates and returns the binary String ; P : Frequency of consecutive characters with sum 0 Q : Frequency of consecutive characters with sum 1 R : Frequency of consecutive characters with sum 2 ; If no consecutive character adds up to 1 ; Not possible if both P and Q are non - zero ; If P is not equal to 0 ; Append 0 P + 1 times ; Append 1 R + 1 times ; Append "01" to satisfy Q ; Append "0" P times ; Append "1" R times ; Driver Code
class GFG { static String build_binary_str ( int p , int q , int r ) { String ans = " " ; if ( q == 0 ) { if ( p != 0 && r != 0 ) { return " - 1" ; } else { if ( p > 0 ) { ans = Strings ( p + 1 , '0' ) ; } else { ans = Strings ( r + 1 , '1' ) ; } } } else { for ( int i = 1 ; i <= q + 1 ; i ++ ) { if ( i % 2 == 0 ) { ans += '0' ; } else { ans += '1' ; } } ans = ans . substring ( 0 , 1 ) + Strings ( p , '0' ) + ans . substring ( 1 ) ; ans = Strings ( r , '1' ) + ans ; } return ans ; } static String Strings ( int p , char c ) { String ans = " " ; for ( int i = 0 ; i < p ; i ++ ) ans += c ; return ans ; } public static void main ( String [ ] args ) { int p = 1 , q = 2 , r = 2 ; System . out . print ( build_binary_str ( p , q , r ) ) ; } }