Longest Increasing Subsequence

Advanced

Longest Increasing Subsequence

Imagine you are climbing a mountain of numbers! You want to find the longest uphill path you can climb without ever stepping downhill. Let's tackle this using code!

Your task is to write a function longest_increasing_subsequence that takes a list of numbers and returns the length of the longest subsequence where every following number is larger than the previous one. A subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements.

For example, in the list [3, 10, 2, 1, 20], the longest increasing subsequence is [3, 10, 20], so the function should return 3.

Examples:

longest_increasing_subsequence([3, 10, 2, 1, 20]) # returns 3 longest_increasing_subsequence([3, 2]) # returns 1 longest_increasing_subsequence([50, 3, 10, 7, 40, 80]) # returns 4 longest_increasing_subsequence([3, 4, 5, 6, 7]) # returns 5

This challenge is great for helping you learn algorithmic thinking and dealing with sequence data. Have fun climbing the number mountain!

Geek
Inputs

Arg 1:

[3,10,2,1,20]
Expected Output
3
Actual Output