Longest Increasing Subsequence
Given an integer array nums, return the length of the longest strictly increasing subsequence. A subsequence keeps the original order but may drop elements; it need not be contiguous.
Open official problem prompt ↗Determine how long the longest run of values can be if we read left to right and only keep values that keep strictly rising.
Dealing cards into piles in the patience card game: each new card goes on the leftmost pile whose top is not smaller, and the number of piles equals the longest increasing subsequence.
- Input
- nums = [10, 9, 2, 5, 3, 7, 101, 18]
- Output
- 4
- Why
- The subsequence [2, 3, 7, 101] (or [2, 3, 7, 18]) is strictly increasing and has length 4.
1 <= nums.length <= 2500-10^4 <= nums[i] <= 10^4