X

DAYS

:

HOUR

:

MINS

:

SEC

Copied to Clipboard
Middle Pattern
Basic Accuracy: 33.82% Submissions: 12845 Points: 1

Given an odd length word your task is to complete the function printPattern that takes a string s as its argument and prints it from the middle of the word such that it follows the following pattern.
 

Input: PROGRAM 
Output:
G$ GR$ GRA$ GRAM$ 
GRAMP$ GRAMPR$ GRAMPRO$

Input: RAT
Output:
A$ AT$ ATR$

NOTE: 
Corresponding to each test case in a new 
line print the pattern in a  single 
line where each row of the pattern 
is separated by a "$" instead 
of a new line.

Constraints:
1 ≤ T ≤ 20
1<=size of string(s)<=20

We are replacing the old Disqus forum with the new Discussions section given below.
Click here to view old Disqus comments.


to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.

Middle Pattern

Output Window