FastPrepFastPrep
Problem Brief

DFS Subsequences of a String (For MLE)

NEW GRADOA

A DFS problem involving subsequences of a string. Given an input String, return a list containing every possible substring, with the requirement that they are sorted alphabetically. For example, given the input "abc", return ["a", "b", "c", "ab", "bc", "ac", "abc"].

1Example 1

Input
s = "abc"
Output
["a", "ab", "abc", "ac", "b", "bc", "c"]
Explanation

The function should return all possible subsequences of the input string "abc" sorted alphabetically, which are: ["a", "ab", "abc", "ac", "b", "bc", "c"].

Constraints

Limits and guarantees your solution can rely on.

🥝🥝
public List<String> generateAllSubsequences(String s) {
  // write your code here
}
Input

s

"abc"

Output

["a", "ab", "abc", "ac", "b", "bc", "c"]

Sign in to submit your solution.