Update appNew update is available. Click here to update.

Subsequences of String

Contributed by
Ankit Kharb
Last Updated: 23 Feb, 2023
Medium
yellow-spark
0/80
Avg time to solve 15 mins
Success Rate 85 %
Share
93 upvotes

Problem Statement

You are given a string 'STR' containing lowercase English letters from a to z inclusive. Your task is to find all non-empty possible subsequences of 'STR'.

A Subsequence of a string is the one which is generated by deleting 0 or more letters from the string and keeping the rest of the letters in the same order.
Detailed explanation ( Input/output format, Notes, Images )
Constraints:
1 <= T <= 10 
1 <=  |STR| <= 16

Where |STR| represents the length of the string 'STR'.

Time Limit: 1 sec
Sample Input 1:
1 
abc
Sample Output 1:
a ab abc ac b bc c
Explanation of sample input 1:
All possible subsequences of abc are :  
“a” , “b” , “c” , “ab” , “bc” , “ac”, “abc”
Sample Input 2:
1
bbb
Sample Output 2:
b b b bb bb bb bbb
Reset Code
Full screen
Auto
copy-code
Console