hardBinary SearchPure DSA~35 min
Longest Strictly Increasing Metric Subsequence
From a stream of metric readings, find the length of the longest strictly increasing subsequence — the longest run of improving values that need not be contiguous.
Problem
Given an integer array nums, return the length of the longest strictly increasing subsequence.
Input
An integer array nums.
Output
An integer: the length of the longest increasing subsequence.
Constraints
- 1 <= nums.length <= 2500
- -10^4 <= nums[i] <= 10^4
- The subsequence need not be contiguous.
Examples
Example 1
Input
nums = [10,9,2,5,3,7,101,18]
Output
4
[2,3,7,18] (or [2,3,7,101]) has length 4.
Example 2
Input
nums = [7,7,7,7,7]
Output
1
Strictly increasing, so only a single 7 counts.