###300. Longest Increasing Subsequence

题目:
<https://leetcode.com/problems/longest-increasing-subsequence/>


难度:
Medium


思路：

典型DP

递推关系式：

对于以num[i]结束的longest increasing subsequence的长度

dp[i] = dp[j] + 1 if num[i] > num[j] else 1

最后loop一圈，求出最长的 

AC 代码

```
class Solution(object):
    def lengthOfLIS(self, nums):
        """
        :type nums: List[int]
        :rtype: int
        """
        if not nums: return 0
        n = len(nums)
        dp = [1 for i in range(n)]
        for i in range(1,n):
        	for j in range(i):
        		if nums[i] > nums[j] :
        			dp[i] = max(dp[i],dp[j] + 1)

        return max(dp)
```

