Skip to content

Practice Longest Increasing Subsequence

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#300
LeetCode Problem

Longest Increasing Subsequence

Problem Statement

Given an integer array nums, return the length of the longest strictly increasing subsequence. Follow up: Can you come up with an algorithm that runs in O(n log(n)) time complexity?

Source: Longest Increasing Subsequence on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

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

# Example 2

Input
nums = [0,1,0,3,2,3]
Output
4

# Example 3

Input
nums = [7,7,7,7,7,7,7]
Output
1

Constraints

1 <= nums.length <= 2500
-10^4 <= nums[i] <= 10^4

Related LeetCode Problems

Practice more problems similar to Longest Increasing Subsequence.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.