Non-decreasing Subsequences
MediumBacktracking
Decode it first. Clues, constraints, pattern and plan before any code.Given a list of integers nums, return every different subsequence that is non-decreasing (each value is at least the one before it) and has at least two elements. A subsequence keeps the original order but may skip elements. Return them in any order.
[4, 6, 7, 7] → [[4, 6], [4, 6, 7], [4, 6, 7, 7], [4, 7], [4, 7, 7], [6, 7], [6, 7, 7], [7, 7]]
[4, 4, 3, 2, 1] → [[4, 4]]Constraints
1 <= nums.length <= 15-100 <= nums[i] <= 100