Leetcode 2826. Sorting Three Groups
Given an array of values in {1,2,3}, remove the fewest elements so the remaining sequence is non-decreasing. This is equivalent to maximizing the length of a non-decreasing subsequence (or a subsequence of the form 1*2*3*), which can be solved with a small-state DP in O(n) time.
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
0
Hello Interview Premium
Your account is free and you can post anonymously if you choose.