Largest Subsequences
Problem statement
Given a lowercase string s of length n, return an array answer of length n.
For every i from 1 through n, answer[i - 1] must be the lexicographically largest subsequence of s whose length is exactly i.
A subsequence is formed by deleting zero or more characters without changing the order of the remaining characters.
Function
getLargestSubsequences(s: String) → String[]Examples
Example 1
s = "hrw"return = ["w","rw","hrw"]For lengths 1, 2, and 3, the lexicographically largest subsequences are w, rw, and hrw.
Example 2
s = "dbca"return = ["d","dc","dca","dbca"]The best subsequence of each length is d, dc, dca, and the complete string dbca.
Constraints
1 <= s.length <= 3000.scontains only lowercase English letters.