Problem · String

DFS Subsequences of a String (For MLE)

Learn this problem
EasyWayfairNEW GRADOA

Problem statement

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"].

Function

generateAllSubsequences(s: String) → List<String>

Examples

Example 1

s = "abc"return = ["a", "ab", "abc", "ac", "b", "bc", "c"]

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

Constraints

🥝🥝

More Wayfair problems

drafts saved locally
public List<String> generateAllSubsequences(String s) {
  // write your code here
}
s"abc"
expected["a", "ab", "abc", "ac", "b", "bc", "c"]
checking account