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 ) ; } }