Print All Subsequences Problem

Print All Subsequences Problem — ExecCode Easy DSA Practice

Solve the Print All Subsequences problem on ExecCode. Free online easy DSA practice in Arrays - Basics. Write and run code in Java, C++, Python — no signup required to run.

Problem description

Given a string s, print all its subsequences. A subsequence is a sequence that can be derived from another sequence by deleting some or no elements without changing the order of the remaining elements. Example: For string "abc", subsequences are "", "a", "b", "c", "ab", "ac", "bc", "abc".

Examples

Input s = "ABC"; Output ["", "C", "B", "BC", "A", "AC", "AB", "ABC"]. Input s = "AB"; Output ["", "B", "A", "AB"]. Input s = "A"; Output ["", "A"]

Constraints

1 <= s.length <= 15 s consists of uppercase English letters.

Practice Print All Subsequences free on ExecCode. Browse DSA problems, topic map, and placement guides.