Editor

Longest Increasing Subsequence

Advanced · Write the code · from 50 Python Practice Problems with Instant Answer Checking (Beginner to Advanced)

From the lesson: 50 Python Practice Problems with Instant Answer Checking (Beginner to Advanced)

Fifty problems, each with a code editor and real tests. Write your solution, press Check, and see exactly which cases pass. Stuck? Hints reveal one at a time, and the solution unlocks once you have checked at least once. Your code and progress are saved in this browser.

Read the lesson

Write lis_length(nums) that returns the length of the longest strictly increasing subsequence (the items do not need to be next to each other).

lis_length([10, 9, 2, 5, 3, 7, 101, 18])  ->  4   (2, 3, 7, 18)
def lis_length(nums):
pass
Solution unlocks after your first Check

What Check runs

Your code runs first, then each of these lines. The output must match exactly.

RunsExpected output
lis_length([10, 9, 2, 5, 3, 7, 101, 18])4
lis_length([7, 7, 7])1

More practice problems

All Python exercises · 50 practice problems