Interview Query

Longest Increasing Subsequence

Start Timer

0:00:00

Upvote
0
Downvote
Save question
Mark as completed
View comments (2)
Next question

Write a Python function called longest_increasing_subsequence that takes a list of integers as input and returns as output the length of the longest increasing subsequence in the list.

Note: An increasing subsequence is a subset of a list where the elements are in strictly increasing order. The subsequence does not have to be contiguous or unique.

Example:

Input:

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

Output:

4

Explanation:

The longest increasing subsequence is [2, 3, 7, 101], for a total length of 4.

.
.
.
.
.


Comments

Loading comments