Medium · Dynamic Programming

Longest Increasing Subsequence

Given an integer array nums, return the length of its longest strictly increasing subsequence — elements taken in their original order, not necessarily adjacent.

Examples

Example 1

[10, 9, 2, 5, 3, 7, 101, 18]

Output: LIS = 4

Example 2

[0, 1, 0, 3, 2, 3]

Output: LIS = 4

Rebuild it in the studio

Read every interview problem free. Ten rooms need no account. A token opens a problem in full — Pro never counts.

More Dynamic Programming problems