Leaderboard
Showing:
Pattern of Strings
School Accuracy: 50.82% Submissions: 4920 Points: 0

Given a string of length N, print the pattern of strings with first line with the given length of string and keep printing in new line the strings in decreasing order of length till you print the single first character of the given string. 

Input: First line of the input contains an integer T denoting the number of test cases. Then T test cases follow. Each test case consist of only one line which contains a string of length N.

Output: Corresponding to each test case, pattern is printed in a new line.

Constraints:
1 <=T<= 30
N = 5

Example:
Input:
2
Geeks
th%ik

Output:
Geeks
Geek
Gee
Ge
G

th%ik
th%i
th%
th
t

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.

Pattern of Strings

Output Window