300. Longest Increasing Subsequence

202401281042
tags: #dp

class Solution(object):
	def lengthOfLIS(self, nums):
		dp = [1] * len(nums)
		res = 1
		for i in range(1, len(nums)):
			for j in range(i):
				if nums[i] > nums[j] and dp[i] < dp[j] + 1:
				dp[i] = dp[j] + 1
		return max(dp)

Reference

https://leetcode.com/problems/longest-increasing-subsequence/