伪装成LIS的简单题目
class Solution(object):
def findLengthOfLCIS(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
n = len(nums)
# guard clause
# 这个可比lis简单多了, 维护两个状态就ok
if n == 1:
return 1
max_lcis = 0
tmp_lcis = 1
for i in range(1,n):
# 关键步骤就在此
if nums[i] > nums[i-1]:
tmp_lcis +=1
else:
tmp_lcis = 1
max_lcis = max(max_lcis,tmp_lcis)
return max_lcis