codeparrot/xlcost-text-to-code huggingface dataset:
Construct a matrix such that union of ith row and ith column contains every element from 1 to 2 N | Java implementation of the above approach ; Function to find the square matrix ; For Matrix of order 1 , it will contain only 1 ; For Matrix of odd order , it is not possible ; For Matrix of even order ; All diagonal elements of the matrix can be N itself . ; Assign values at desired place in the matrix ; Loop to add N in the lower half of the matrix such that it contains elements from 1 to 2 * N - 1 ; Loop to print the matrix ; Driver Code
class GFG { static int matrix [ ] [ ] = new int [ 100 ] [ 100 ] ; static void printRequiredMatrix ( int n ) { if ( n == 1 ) { System . out . println ( "1" ) ; } else if ( n % 2 != 0 ) { System . out . println ( " - 1" ) ; } else { for ( int i = 0 ; i < n ; i ++ ) { matrix [ i ] [ i ] = n ; } int u = n - 1 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { matrix [ i ] [ u ] = i + 1 ; for ( int j = 1 ; j < n / 2 ; j ++ ) { int a = ( i + j ) % ( n - 1 ) ; int b = ( i - j + n - 1 ) % ( n - 1 ) ; if ( a < b ) { int temp = a ; a = b ; b = temp ; } matrix [ b ] [ a ] = i + 1 ; } } for ( int i = 0 ; i < n ; i ++ ) for ( int j = 0 ; j < i ; j ++ ) matrix [ i ] [ j ] = matrix [ j ] [ i ] + n ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) System . out . print ( matrix [ i ] [ j ] + " ▁ " ) ; System . out . println ( ) ; } } System . out . println ( ) ; } public static void main ( String [ ] args ) { int n = 1 ; printRequiredMatrix ( n ) ; n = 3 ; printRequiredMatrix ( n ) ; n = 6 ; printRequiredMatrix ( n ) ; } }
Count of sub | Java implementation of the above approach ; Function to find the count of substrings with equal no . of consecutive 0 ' s ▁ and ▁ 1' s ; To store the total count of substrings ; Traversing the string ; Count of consecutive 0 ' s ▁ & ▁ 1' s ; Counting subarrays of type "01" ; Count the consecutive 0 's ; If consecutive 0 ' s ▁ ▁ ends ▁ then ▁ check ▁ for ▁ ▁ consecutive ▁ 1' s ; Counting consecutive 1 's ; Counting subarrays of type "10" ; Count consecutive 1 's ; If consecutive 1 ' s ▁ ▁ ends ▁ then ▁ check ▁ for ▁ ▁ consecutive ▁ 0' s ; Count consecutive 0 's ; Update the total count of substrings with minimum of ( cnt0 , cnt1 ) ; Return answer ; Driver code ; Function to print the count of substrings
class GFG { static int countSubstring ( String S , int n ) { int ans = 0 ; int i = 0 ; while ( i < n ) { int cnt0 = 0 , cnt1 = 0 ; if ( S . charAt ( i ) == '0' ) { while ( i < n && S . charAt ( i ) == '0' ) { cnt0 ++ ; i ++ ; } int j = i ; while ( j < n && S . charAt ( j ) == '1' ) { cnt1 ++ ; j ++ ; } } else { while ( i < n && S . charAt ( i ) == '1' ) { cnt1 ++ ; i ++ ; } int j = i ; while ( j < n && S . charAt ( j ) == '0' ) { cnt0 ++ ; j ++ ; } } ans += Math . min ( cnt0 , cnt1 ) ; } return ans ; } static public void main ( String args [ ] ) { String S = "0001110010" ; int n = S . length ( ) ; System . out . println ( countSubstring ( S , n ) ) ; } }
Print N numbers such that their sum is a Perfect Cube | Java implementation to find the N numbers such that their sum is a perfect cube ; Function to find the N numbers such that their sum is a perfect cube ; Loop to find the Ith term of the Centered Hexagonal number ; Driver Code ; Function Call
class GFG { static void findNumbers ( int n ) { int i = 1 ; while ( i <= n ) { System . out . print ( ( 3 * i * ( i - 1 ) + 1 ) + " ▁ " ) ; i ++ ; } } public static void main ( String [ ] args ) { int n = 4 ; findNumbers ( n ) ; } }
Largest N digit Octal number which is a Perfect square | Java implementation to find the maximum N - digit octal number which is perfect square ; Function to convert decimal number to a octal number ; Array to store octal number ; Counter for octal number array ; Store remainder in octal array ; Print octal number array in reverse order ; Largest n - digit perfect square ; Driver code
import java . util . * ; import java . lang . * ; import java . io . * ; class GFG { static void decToOctal ( int n ) { int octalNum [ ] = new int [ 100 ] ; int i = 0 ; while ( n != 0 ) { octalNum [ i ] = n % 8 ; n = n / 8 ; i ++ ; } for ( int j = i - 1 ; j >= 0 ; j -- ) System . out . print ( octalNum [ j ] ) ; System . out . println ( "NEW_LINE"); } static void nDigitPerfectSquares ( int n ) { int decimal = ( int ) Math . pow ( Math . ceil ( Math . sqrt ( Math . pow ( 8 , n ) ) ) - 1 , 2 ) ; decToOctal ( decimal ) ; } public static void main ( String [ ] args ) { int n = 2 ; nDigitPerfectSquares ( n ) ; } }
Reverse the substrings of the given String according to the given Array of indices | Java implementation to reverse the subStrings of the given String according to the given Array of indices ; Function to reverse a String ; Swap character starting from two corners ; Function to reverse the String with the given array of indices ; Reverse the String from 0 to A [ 0 ] ; Reverse the String for A [ i ] to A [ i + 1 ] ; Reverse String for A [ n - 1 ] to length ; Driver Code
class GFG { static String s ; static void reverseStr ( int l , int h ) { int n = h - l ; for ( int i = 0 ; i < n / 2 ; i ++ ) { s = swap ( i + l , n - i - 1 + l ) ; } } static void reverseString ( int A [ ] , int n ) { reverseStr ( 0 , A [ 0 ] ) ; for ( int i = 1 ; i < n ; i ++ ) reverseStr ( A [ i - 1 ] , A [ i ] ) ; reverseStr ( A [ n - 1 ] , s . length ( ) ) ; } static String swap ( int i , int j ) { char ch [ ] = s . toCharArray ( ) ; char temp = ch [ i ] ; ch [ i ] = ch [ j ] ; ch [ j ] = temp ; return String . valueOf ( ch ) ; } public static void main ( String [ ] args ) { s = " abcdefgh " ; int A [ ] = { 2 , 4 , 6 } ; int n = A . length ; reverseString ( A , n ) ; System . out . print ( s ) ; } }
Check if the Depth of Parentheses is correct in the given String | Function to check if the Depth of Parentheses is correct in the given String ; Appending if the Character is not integer ; Iterating till the entire Digit is read ; Check if character is ' ( ' ; Increment depth by 1 ; Increment open by 1 ; Check if character is ' ) ' ; Decrement depth by 1 ; Increment close by 1 ; Check if open parentheses NOT equals close parentheses ; Driver Code
import java . util . * ; class GFG { static boolean Formatted ( String s ) { Vector < Character > k = new Vector < Character > ( ) ; int i = 0 ; while ( i < s . length ( ) ) { if ( s . charAt ( i ) == ' ) ' || s . charAt ( i ) == ' ( ' ) { k . add ( s . charAt ( i ) ) ; i += 1 ; } else { char st = 0 ; while ( s . charAt ( i ) != ' ) ' && s . charAt ( i ) != ' ) ' ) { st = s . charAt ( i ) ; i = i + 1 ; } k . add ( st ) ; } } int depth = 0 , flag = 1 ; int open = 0 , close = 0 ; for ( char i2 : k ) { if ( i2 == ' ( ' ) { depth += 1 ; open += 1 ; } else if ( i2 == ' ) ' ) { depth -= 1 ; close += 1 ; } else { if ( i2 - '0' != depth ) { flag = 0 ; break ; } } } if ( open != close ) flag = 0 ; return ( flag == 1 ) ? true : false ; } public static void main ( String [ ] args ) { String s = " ( (2 ) ( (3 ) ) ) " ; boolean k = Formatted ( s ) ; if ( k == true ) System . out . printf ( " Yes " ) ; else System . out . printf ( " No " ) ; } }
Maximize the sum of differences of consecutive elements after removing exactly K elements | Java implementation of the approach ; Function to return the maximized sum ; Remove any k internal elements ; Driver code
class GFG { static int findSum ( int [ ] arr , int n , int k ) { if ( k <= n - 2 ) return ( arr [ n - 1 ] - arr [ 0 ] ) ; return 0 ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 3 , 4 } ; int n = arr . length ; int k = 1 ; System . out . println ( findSum ( arr , n , k ) ) ; } }
Split the binary string into substrings with equal number of 0 s and 1 s | Java implementation of the above approach ; Function to return the count of maximum substrings str can be divided into ; To store the count of 0 s and 1 s ; To store the count of maximum substrings str can be divided into ; It is not possible to split the string ; Driver code
class GFG { static int maxSubStr ( String str , int n ) { int count0 = 0 , count1 = 0 ; int cnt = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( str . charAt ( i ) == '0' ) { count0 ++ ; } else { count1 ++ ; } if ( count0 == count1 ) { cnt ++ ; } } if ( cnt == 0 ) { return - 1 ; } return cnt ; } public static void main ( String [ ] args ) { String str = "0100110101" ; int n = str . length ( ) ; System . out . println ( maxSubStr ( str , n ) ) ; } }
Sum of the digits of square of the given number which has only 1 's as its digits | Java implementation of the approach ; Function to return the sum of the digits of num ^ 2 ; To store the number of 1 's ; Find the sum of the digits of num ^ 2 ; Driver code
class GFG { static long squareDigitSum ( String s ) { long lengthN = s . length ( ) ; long result = ( lengthN / 9 ) * 81 + ( long ) Math . pow ( ( lengthN % 9 ) , 2 ) ; return result ; } public static void main ( String [ ] args ) { String s = "1111" ; System . out . println ( squareDigitSum ( s ) ) ; } }
Check whether two strings contain same characters in same order | Java implementation of the approach ; String class has a constructor that allows us to specify size of String as first parameter and character to be filled in given size as second parameter . ; Function that returns true if the given Strings contain same characters in same order ; Get the first character of both Strings ; Now if there are adjacent similar character remove that character from s1 ; Now if there are adjacent similar character remove that character from s2 ; If both the Strings are equal then return true ; Driver code
class temp { static String getString ( char x ) { String s = String . valueOf ( x ) ; return s ; } static boolean solve ( String s1 , String s2 ) { String a = getString ( s1 . charAt ( 0 ) ) , b = getString ( s2 . charAt ( 0 ) ) ; for ( int i = 1 ; i < s1 . length ( ) ; i ++ ) if ( s1 . charAt ( i ) != s1 . charAt ( i - 1 ) ) { a += getString ( s1 . charAt ( i ) ) ; } for ( int i = 1 ; i < s2 . length ( ) ; i ++ ) if ( s2 . charAt ( i ) != s2 . charAt ( i - 1 ) ) { b += getString ( s2 . charAt ( i ) ) ; } if ( a . equals ( b ) ) return true ; return false ; } public static void main ( String [ ] args ) { String s1 = " Geeks " , s2 = " Geks " ; if ( solve ( s1 , s2 ) ) System . out . print ( " Yes " ) ; else System . out . print ( " No " ) ; } }
Count number of distinct substrings of a given length | Java implementation of above approach ; Function to find the required count ; Variable to the hash ; Finding hash of substring ( 0 , l - 1 ) using random number x ; Computing x ^ ( l - 1 ) ; Unordered set to add hash values ; Generating all possible hash values ; Print the result ; Driver Code
import java . util . * ; class GFG { static int x = 26 ; static int mod = 3001 ; static void CntSubstr ( char [ ] s , int l ) { int hash = 0 ; for ( int i = 0 ; i < l ; i ++ ) { hash = ( hash * x + ( s [ i ] - 97 ) ) % mod ; } int pow_l = 1 ; for ( int i = 0 ; i < l - 1 ; i ++ ) { pow_l = ( pow_l * x ) % mod ; } HashSet < Integer > result = new HashSet < Integer > ( ) ; result . add ( hash ) ; for ( int i = l ; i < s . length ; i ++ ) { hash = ( ( hash - pow_l * ( s [ i - l ] - 97 ) + 2 * mod ) * x + ( s [ i ] - 97 ) ) % mod ; result . add ( hash ) ; } System . out . println ( result . size ( ) ) ; } public static void main ( String [ ] args ) { String s = " abcba " ; int l = 2 ; CntSubstr ( s . toCharArray ( ) , l ) ; } }
Check if a binary string has two consecutive occurrences of one everywhere | Java implementation of the approach ; Function that returns 1 if str is valid ; Index of first appearance of ' b ' ; If str starts with ' b ' ; While ' b ' occurs in str ; If ' b ' doesn ' t ▁ appear ▁ after ▁ an ▁ ' a ' ; If ' b ' is not succeeded by another ' b ' ; If sub - string is of the type " abbb " ; If str ends with a single b ; Driver code
class GFG { private static boolean isValidString ( String str , int n ) { int index = str . indexOf ( " b " ) ; if ( index == 0 ) return false ; while ( index != - 1 ) { if ( str . charAt ( index - 1 ) != ' a ' ) return false ; if ( index + 1 < n && str . charAt ( index + 1 ) != ' b ' ) return false ; if ( index + 2 < n && str . charAt ( index + 2 ) == ' b ' ) return false ; if ( index == n - 1 ) return false ; index = str . indexOf ( " b " , index + 2 ) ; } return true ; } public static void main ( String [ ] args ) { String str = " abbaaabbabba " ; int n = str . length ( ) ; System . out . println ( isValidString ( str , n ) ) ; } }
Count strings that end with the given pattern | Java implementation of the approach ; Function that return true if str ends with pat ; Pattern is larger in length than the string ; We match starting from the end while patLen is greater than or equal to 0. ; If at any index str doesn 't match  with pattern ; If str ends with the given pattern ; Function to return the count of required strings ; If current string ends with the given pattern ; Driver code
class GfG { static boolean endsWith ( String str , String pat ) { int patLen = pat . length ( ) ; int strLen = str . length ( ) ; if ( patLen > strLen ) return false ; patLen -- ; strLen -- ; while ( patLen >= 0 ) { if ( pat . charAt ( patLen ) != str . charAt ( strLen ) ) return false ; patLen -- ; strLen -- ; } return true ; } static int countOfStrings ( String pat , int n , String sArr [ ] ) { int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( endsWith ( sArr [ i ] , pat ) ) count ++ ; } return count ; } public static void main ( String [ ] args ) { String pat = " ks " ; int n = 4 ; String sArr [ ] = { " geeks " , " geeksforgeeks " , " games " , " unit " } ; System . out . println ( countOfStrings ( pat , n , sArr ) ) ; } }
Length of the longest substring with consecutive characters | Java implementation of the approach ; Function to return the ending index for the largest valid sub - string starting from index i ; If the current character appears after the previous character according to the given circular alphabetical order ; Function to return the length of the longest sub - string of consecutive characters from str ; Valid sub - string exists from index i to end ; Update the length ; Driver code
class GFG { static int getEndingIndex ( String str , int n , int i ) { i ++ ; while ( i < n ) { char curr = str . charAt ( i ) ; char prev = str . charAt ( i - 1 ) ; if ( ( curr == ' a ' && prev == ' z ' ) || ( curr - prev == 1 ) ) i ++ ; else break ; } return i - 1 ; } static int largestSubStr ( String str , int n ) { int len = 0 ; int i = 0 ; while ( i < n ) { int end = getEndingIndex ( str , n , i ) ; len = Math . max ( end - i + 1 , len ) ; i = end + 1 ; } return len ; } public static void main ( String args [ ] ) { String str = " abcabcdefabc " ; int n = str . length ( ) ; System . out . print ( largestSubStr ( str , n ) ) ; } }
Sum of integers upto N with given unit digit ( Set 2 ) | Java implementation of the approach ; Function to return the required sum ; Decrement N ; Driver code
import java . io . * ; class GFG { static long getSum ( long n , int d ) { if ( n < d ) return 0 ; while ( n % 10 != d ) n -- ; long k = n / 10 ; return ( k + 1 ) * d + ( k * 10 + 10 * k * k ) / 2 ; } public static void main ( String [ ] args ) { long n = 30 ; int d = 3 ; System . out . println ( getSum ( n , d ) ) ; } }
Maximum possible time that can be formed from four digits | Java implementation of the approach ; Function to return the updated frequency map for the array passed as argument ; Function that returns true if the passed digit is present in the map after decrementing it 's frequency by 1 ; If map contains the digit ; Decrement the frequency of the digit by 1 ; True here indicates that the digit was found in the map ; Digit not found ; Function to return the maximum possible time in 24 - Hours format ; First digit of hours can be from the range [ 0 , 2 ] ; If no valid digit found ; If first digit of hours was chosen as 2 then the second digit of hours can be from the range [ 0 , 3 ] ; Else it can be from the range [ 0 , 9 ] ; Hours and minutes separator ; First digit of minutes can be from the range [ 0 , 5 ] ; Second digit of minutes can be from the range [ 0 , 9 ] ; Return the maximum possible time ; Driver code
import java . util . * ; public class GFG { static HashMap < Integer , Integer > getFrequencyMap ( int arr [ ] ) { HashMap < Integer , Integer > hashMap = new HashMap < > ( ) ; for ( int i = 0 ; i < arr . length ; i ++ ) { if ( hashMap . containsKey ( arr [ i ] ) ) { hashMap . put ( arr [ i ] , hashMap . get ( arr [ i ] ) + 1 ) ; } else { hashMap . put ( arr [ i ] , 1 ) ; } } return hashMap ; } static boolean hasDigit ( HashMap < Integer , Integer > hashMap , int digit ) { if ( hashMap . containsKey ( digit ) && hashMap . get ( digit ) > 0 ) { hashMap . put ( digit , hashMap . get ( digit ) - 1 ) ; return true ; } return false ; } static String getMaxTime ( int arr [ ] ) { HashMap < Integer , Integer > hashMap = getFrequencyMap ( arr ) ; int i ; boolean flag ; String time = " " ; flag = false ; for ( i = 2 ; i >= 0 ; i -- ) { if ( hasDigit ( hashMap , i ) ) { flag = true ; time += i ; break ; } } if ( ! flag ) { return " - 1" ; } flag = false ; if ( time . charAt ( 0 ) == '2' ) { for ( i = 3 ; i >= 0 ; i -- ) { if ( hasDigit ( hashMap , i ) ) { flag = true ; time += i ; break ; } } } else { for ( i = 9 ; i >= 0 ; i -- ) { if ( hasDigit ( hashMap , i ) ) { flag = true ; time += i ; break ; } } } if ( ! flag ) { return " - 1" ; } time += " : " ; flag = false ; for ( i = 5 ; i >= 0 ; i -- ) { if ( hasDigit ( hashMap , i ) ) { flag = true ; time += i ; break ; } } if ( ! flag ) { return " - 1" ; } flag = false ; for ( i = 9 ; i >= 0 ; i -- ) { if ( hasDigit ( hashMap , i ) ) { flag = true ; time += i ; break ; } } if ( ! flag ) { return " - 1" ; } return time ; } public static void main ( String [ ] args ) { int arr [ ] = { 0 , 0 , 0 , 9 } ; System . out . println ( getMaxTime ( arr ) ) ; } }
Most frequent word in first String which is not present in second String | Java implementation of above approach ; Function to return frequent word from S1 that isn 't  present in S2 ; create map of banned words ; find smallest and most frequent word ; check if word is not banned ; return answer ; Driver Code
import java . util . HashMap ; class GFG { static String smallestFreq ( String S1 , String S2 ) { HashMap < String , Integer > banned = new HashMap < > ( ) ; for ( int i = 0 ; i < S2 . length ( ) ; i ++ ) { String s = " " ; while ( i < S2 . length ( ) && S2 . charAt ( i ) != ' ▁ ' ) s += S2 . charAt ( i ++ ) ; banned . put ( s , banned . get ( s ) == null ? 1 : banned . get ( s ) + 1 ) ; } HashMap < String , Integer > result = new HashMap < > ( ) ; String ans = " " ; int freq = 0 ; for ( int i = 0 ; i < S1 . length ( ) ; i ++ ) { String s = " " ; while ( i < S1 . length ( ) && S1 . charAt ( i ) != ' ▁ ' ) s += S1 . charAt ( i ++ ) ; if ( banned . get ( s ) == null ) { result . put ( s , result . get ( s ) == null ? 1 : result . get ( s ) + 1 ) ; if ( result . get ( s ) > freq || ( result . get ( s ) == freq && s . compareTo ( ans ) < 0 ) ) { ans = s ; freq = result . get ( s ) ; } } } return ans ; } public static void main ( String [ ] args ) { String S1 = " geeks ▁ for ▁ geeks ▁ is ▁ best ▁ place ▁ to ▁ learn " ; String S2 = " bad ▁ place " ; System . out . println ( smallestFreq ( S1 , S2 ) ) ; } }
Minimum characters to be replaced to remove the given substring | Java implementation of above approach ; function to calculate minimum characters to replace ; mismatch occurs ; if all characters matched , i . e , there is a substring of ' a ' which is same as string ' b ' ; increment i to index m - 1 such that minimum characters are replaced in ' a ' ; Driver Code
import java . io . * ; class GFG { static int replace ( String A , String B ) { int n = A . length ( ) , m = B . length ( ) ; int count = 0 , i , j ; for ( i = 0 ; i < n ; i ++ ) { for ( j = 0 ; j < m ; j ++ ) { if ( i + j >= n ) break ; else if ( A . charAt ( i + j ) != B . charAt ( j ) ) break ; } if ( j == m ) { count ++ ; i += m - 1 ; } } return count ; } public static void main ( String args [ ] ) { String str1 = " aaaaaaaa " ; String str2 = " aaa " ; System . out . println ( replace ( str1 , str2 ) ) ; } }
Check if a string is substring of another | Java program to check if a string is substring of other . ; Returns true if s1 is substring of s2 ; A loop to slide pat [ ] one by one ; For current index i , check for pattern match ; Driver code
class GFG { static int isSubstring ( String s1 , String s2 ) { int M = s1 . length ( ) ; int N = s2 . length ( ) ; for ( int i = 0 ; i <= N - M ; i ++ ) { int j ; for ( j = 0 ; j < M ; j ++ ) if ( s2 . charAt ( i + j ) != s1 . charAt ( j ) ) break ; if ( j == M ) return i ; } return - 1 ; } public static void main ( String args [ ] ) { String s1 = " for " ; String s2 = " geeksforgeeks " ; int res = isSubstring ( s1 , s2 ) ; if ( res == - 1 ) System . out . println ( " Not ▁ present " ) ; else System . out . println ( " Present ▁ at ▁ index ▁ " + res ) ; } }
Splitting a Numeric String | Java program to split a numeric string in an Increasing sequence if possible ; Function accepts a string and checks if string can be split . ; if there is only 1 number in the string then it is not possible to split it ; storing the substring from 0 to i + 1 to form initial number of the increasing sequence ; convert string to integer and add 1 and again convert back to string s2 ; if s2 is not a substring of number than not possible ; if s2 is the next substring of the numeric string ; Incearse num2 by 1 i . e the next number to be looked for ; check if string is fully traversed then break ; If next string doesnot occurs in a given numeric string then it is not possible ; if the string was fully traversed and conditions were satisfied ; if conditions failed to hold ; Driver Code ; Call the split function for splitting the string
import java . io . * ; import java . util . * ; class GFG { public static void split ( String str ) { int len = str . length ( ) ; if ( len == 1 ) { System . out . println ( " Not ▁ Possible " ) ; return ; } String s1 = " " , s2 = " " ; long num1 , num2 ; for ( int i = 0 ; i <= len / 2 ; i ++ ) { int flag = 0 ; s1 = str . substring ( 0 , i + 1 ) ; num1 = Long . parseLong ( ( s1 ) ) ; num2 = num1 + 1 ; s2 = Long . toString ( num2 ) ; int k = i + 1 ; while ( flag == 0 ) { int l = s2 . length ( ) ; if ( k + l > len ) { flag = 1 ; break ; } if ( ( str . substring ( k , k + l ) . equals ( s2 ) ) ) { flag = 0 ; num2 ++ ; k = k + l ; if ( k == len ) break ; s2 = Long . toString ( num2 ) ; l = s2 . length ( ) ; if ( k + 1 > len ) { flag = 1 ; break ; } } else flag = 1 ; } if ( flag == 0 ) { System . out . println ( " Possible " + " ▁ " + s1 ) ; break ; } else if ( flag == 1 && i > len / 2 - 1 ) { System . out . println ( " Not ▁ Possible " ) ; break ; } } } public static void main ( String args [ ] ) { Scanner in = new Scanner ( System . in ) ; String str = "99100" ; split ( str ) ; } }