479. Divide Array Into Increasing Sequences
Given an integer array nums sorted in non-decreasing order and an integer k, return true if this array can be divided into one or more disjoint increasing subsequences of length at least k, or false otherwise.
Example 1:
Input: nums = [2,3,3,4,4,5,5], k = 3
Output: true
Explanation: The array can be divided into two subsequences [2,3,4,5] and [3,4,5] with lengths at least 3 each.
Example 2:
Input: nums = [1,2,3,3,4], k = 3
Output: false
Explanation: There is no way to divide the array using above condition.
Now Your Turn!
Pick the correct output for the given inputInput: nums = [1,2,3], k = 2
Still unsure what the problem is asking ?
Let’s go through a few more examples, step by step, to make it clearer.
Constraints:
- 1 <= k <= nums.length <= 105
- 1 <= nums[i] <= 105
- nums is sorted in non-decreasing order.