cheetcode

109. Longest Increasing SubsequenceMedium

Return the length of the longest strictly increasing subsequence.

Given an integer array nums, return the length of the longest strictly increasing subsequence.

A subsequence can skip elements, but must preserve relative order.

Examples

Input: nums = [10,9,2,5,3,7,101,18]
Output: 4
Input: nums = [0,1,0,3,2,3]
Output: 4

Constraints

  • 1 <= nums.length <= 2,500
  • -10,000 <= nums[i] <= 10,000