#491
Non-decreasing Subsequences
specialist · 675 · lc medium +30 · verified · 62.5% accepted · 3,811 likes · top 64%
Description
Given an integer array nums, find every distinct subsequence of length at least two whose elements are in non-decreasing order. Return all such subsequences in any order.
Example 1:
Input: nums = [4,6,7,7]
Output: [[4,6],[4,6,7],[4,6,7,7],[4,7],[4,7,7],[6,7],[6,7,7],[7,7]]
Example 2:
Input: nums = [4,4,3,2,1]
Output: [[4,4]]
Code
1
2
3