```
class Solution(object):
def lengthOfLIS(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
dp = []
for num in nums:
i = bisect.bisect_left(dp, num)
if len(dp) <= i:
dp.append(num)
else:
dp[i] = num
return len(dp)
```