Facebook Pixel

Longest Increasing Subsequence

Input & Output
Input
nums — the integer sequence
Output
the length of longest increasing subsequence
Example
Input
nums = [50, 3, 10, 7, 40, 80]
Output
4
Explanation

The longest increasing subsequence is [3, 7, 40, 80] which has length 4.

Example
Input
nums = [1, 2, 4, 3]
Output
3
Explanation

Both [1, 2, 4] and [1, 2, 3] are longest increasing subsequences which have length 3.

Try it yourself

Invest in Yourself
Your new job is waiting. 83% of people that complete the program get a job offer. Unlock unlimited access to all content and features.
Go Pro