300. Longest Increasing Subsequence

300. Longest Increasing Subsequence

[Medium] “Given an unsorted array of integers, find the length of longest increasing subsequence."

Link to Leetcode

Python3:

class Solution:
    def lengthOfLIS(self, nums: List[int]) -> int:
        if not nums:
            return 0
        
        res = [1] * len(nums)
        
        for i in range (1, len(nums)):
            for j in range(i):
                if nums[i] > nums[j]:
                    res[i] = max(res[i], res[j] + 1)
                    
        return max(res)