Problem
You get an integer array nums. Return the length of the longest strictly increasing subsequence of nums.
A subsequence is a sequence that you get when you remove zero or more items from the array. The remaining items keep their order.
In a strictly increasing sequence, each item is larger than the item before it.
Example 1
- Input:
- nums = [5,2,8,6,3,6,9,7]
- Output:
- 4
- Explanation:
- One longest subsequence is
[2, 3, 6, 9]. Another one is[2, 3, 6, 7].
Example 2
- Input:
- nums = [4,4,4]
- Output:
- 1
- Explanation:
- Equal items are not strictly increasing. So each increasing subsequence has only one item.
Example 3
- Input:
- nums = [10,1,11,2,12,3]
- Output:
- 3
- Explanation:
- Both
[10, 11, 12]and[1, 2, 3]have the length 3.
Constraints
- 1 <= nums.length <= 2500
- -10^4 <= nums[i] <= 10^4
Follow-up
Find a solution that runs in O(n log n) time.
SysRound wrote this statement. A reference solution checks every example.
Related questions
Continue with questions that share topics or the same question type.
- Maximum Profit in Job Scheduling
Coding · Array · Binary Search · Dynamic Programming
- Partition Array Into Two Arrays to Minimize Sum Difference
Coding · Array · Binary Search · Bit Manipulation
- Split Array Largest Sum
Coding · Array · Binary Search · Dynamic Programming
- Two Best Non-Overlapping Events
Coding · Array · Binary Search · Dynamic Programming
Sources · 2 references
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 1 record
No company association
Leetcode 300. Longest Increasing Subsequence
Reported date not specified · 0 source reports
Source snapshot: Nov 12, 2026
View source
LeetCode company tags · 1 record
PayPal
Longest Increasing Subsequence
Reported date not specified · Source window: 6mo
Source snapshot: Oct 20, 2026
Source frequency score: 78.2. This is not an interview probability.
View source