Print all possible strings
Submissions: 3443   Accuracy:


  Difficulty: Basic   Marks: 1

Given a string str your task is to complete the function printSpaceString which takes only one argument the string str and  prints all possible strings that can be made by placing spaces (zero or one) in between them. 

For eg .  for the string abc all valid strings will be
                ab c
                a bc
                a b c

The First line of input takes an integer T denoting the number of test cases . Then T test cases follow . Each line of test case contains a string str .

For each test case output the strings possible in a single line  separated by a "$" 

1<=length of string str <=100



abc$ab c$a bc$a b c$

Note:The Input/Ouput format and Example given are used for system's internal purpose, and should be used by a user for Expected Output only. As it is a function problem, hence a user should not read any input from stdin/console. The task is to complete the function specified, and not to write the full code.


** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Amit Khandelwal
Author: Shubham Joshi 1

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

Need help with your code? Please use, generate link and share the link here.

to report an issue on this page.