New update is available. Click here to update.
sidenav-btnClose
Topic list
Subsequences of String
MEDIUM
15 mins
68 upvotes
Strings
Topics (Covered in this problem)
Problem solved
Skill meter
Strings
-
Other topics
Problem solved
Skill meter
Matrices (2D Arrays)
-
Sorting
-
Binary Search
-
Linked List
-
Stacks & Queues
-
Trees
-
Graph
-
Dynamic Programming
-
Greedy
-
Tries
-
Arrays
-
Binary Search Trees
-
Heap
-
Bit Manipulation
-

Subsequences of String

Contributed by
Ankit Kharb
Medium
Avg time to solve 15 mins
Success Rate 85 %
Share
68 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, Constraints, Images )
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
copy-code
Console