Solvarch
DSA ProblemsProgressPlanRoadmapsReviewCheat SheetsCompaniesSystem DesignCS FundamentalsQuestion Bank
Theme
Problems

Longest Increasing Subsequence

Medium
dynamic-programmingbinary-searcharray

Return the length of the longest strictly increasing subsequence of nums (elements keep their order but need not be contiguous).

Input: one line of space-separated integers. Output: the LIS length.

Example 1
Input:
10 9 2 5 3 7 101 18
Output:
4

[2,3,7,101] (or [2,5,7,18]).

Example 2
Input:
0 1 0 3 2 3
Output:
4
Example 3
Input:
7 7 7 7
Output:
1

Constraints

  • 1 ≤ nums.length ≤ 2500
  • -10^4 ≤ nums[i] ≤ 10^4
Watch a video walkthrough

Run your code against the sample tests, or Submit to run the full suite.