> For the complete documentation index, see [llms.txt](https://zcjian.gitbook.io/project/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://zcjian.gitbook.io/project/string/number-of-longest-increasing-subsequence-i-and-ii.md).

# Number of Longest Increasing Subsequence I & II

LeetCode 300 & 673

```python
"""
LeetCode 300 Easy One
"""
class Solution:
    def lengthOfLIS(self, nums):
        """
        :type nums: List[int]
        :rtype: int
        """
        """
        Input: [10,9,2,5,3,7,101,18]
        Output: 4 
        兩個指標
        [10,9,2,5,3,7,101,18]
          1 1 1 1 1 1   1  1
                2 2 2
        """
        if not nums:
            return 0
        s = [1] * len(nums)
        for i in range(1, len(nums)):
            for j in range(i):
                if nums[i] > nums[j]:
                    if s[i] == s[j]:
                        s[i] = s[j] + 1       
        return max(s)
```
