All problems
Longest Increasing Subsequence
Problem
Return the length of the longest strictly increasing subsequence of arr using the O(n squared) dynamic programming approach.
Let dp[i] be the length of the longest increasing subsequence ending at index i; extend it from any earlier index j where arr[j] < arr[i]. Return 0 for an empty list.
Hint
The subsequence does not need to be contiguous, only strictly increasing.
Test cases
case 1
in: [[10,9,2,5,3,7,101,18]]
expected: 4
case 2
in: [[1,2,3,4,5]]
expected: 5
case 3
in: [[5,4,3,2,1]]
expected: 1
case 4
in: [[]]
expected: 0
case 5
in: [[7,7,7]]
expected: 1
Starter codePython
def lis_length(arr):
# Your code here
pass5 test cases · run your code against them in the editor