Problems
Scratchpad
Run
Submit
0
0
1
2
3
4
5
6
7
8
9
0
0
1
2
3
4
5
6
7
8
9
:
0
0
1
2
3
4
5
6
7
8
9
0
0
1
2
3
4
5
6
7
8
9
Toggle theme (Current: Custom)
Scratchpad
Run
Submit
Description
Hints
Solutions
3202. Find the Maximum Length of Valid Subsequence II
Medium
30 Points
Array
Dynamic Programming
A subsequence sub of nums with length x is called valid if it satisfies:
Examples
Example 1
Input: nums = [1,2,3,4,5], k = 2 Output: 5 Explanation: The longest valid subsequence is [1, 2, 3, 4, 5] .
Example 2
Input: nums = [1,4,2,3,1,4], k = 3 Output: 4 Explanation: The longest valid subsequence is [1, 4, 1, 4] .
Constraints
2 <= nums.length <= 103
1 <= nums[i] <= 107
1 <= k <= 103
JAVASCRIPT
Code
Tests
Result
Description
Hints
Solutions
3202. Find the Maximum Length of Valid Subsequence II
Medium
30 Points
Array
Dynamic Programming
A subsequence sub of nums with length x is called valid if it satisfies:
Examples
Example 1
Input: nums = [1,2,3,4,5], k = 2 Output: 5 Explanation: The longest valid subsequence is [1, 2, 3, 4, 5] .
Example 2
Input: nums = [1,4,2,3,1,4], k = 3 Output: 4 Explanation: The longest valid subsequence is [1, 4, 1, 4] .
Constraints
2 <= nums.length <= 103
1 <= nums[i] <= 107
1 <= k <= 103
JAVASCRIPT
Code
Tests
Result
Find the Maximum Length of Valid Subsequence II - Practice Coding | SlaveCode