Proficient Level
Implement the method longestIncreasingSubsequence that returns the length of the longest strictly increasing subsequence.
A subsequence keeps original order but may skip elements. The chosen values must be strictly increasing.
The task is designed to test careful handling of edge cases, not only the most common input.
- Use only the first
sizeelements. - Return the length, not the subsequence itself.
- Equal values cannot extend a strictly increasing subsequence.
Let dp[i] be the best subsequence length ending at index i, then extend from earlier smaller values.