Created
August 12, 2018 10:00
-
-
Save luojiyin1987/b86f408ff5716ebcca2dd9251b871cf7 to your computer and use it in GitHub Desktop.
Longest Continuous Increasing Subsequence
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Solution(object): | |
| def findLengthOfLCIS(self, nums): | |
| """ | |
| :type nums: List[int] | |
| :rtype: int | |
| """ | |
| nums_length = len(nums) | |
| if nums_length <=1: | |
| return nums_length | |
| max_length = 0 | |
| count = 1 | |
| lastNum = nums[0] | |
| for num in nums[1:]: | |
| if num > lastNum: | |
| count +=1 | |
| else: | |
| count = 1 | |
| lastNum = num | |
| if count > max_length: | |
| max_length = count | |
| return max_length |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment