Seawolf 发表于 2020-8-4 00:57:56

Leetcode 674. Longest Continuous Increasing Subsequence

Given an unsorted array of integers, find the length of longest continuous increasing subsequence (subarray).

Example 1:
Input:
Output: 3
Explanation: The longest continuous increasing subsequence is , its length is 3.
Even though is also an increasing subsequence, it's not a continuous one where 5 and 7 are separated by 4.
Example 2:
Input:
Output: 1
Explanation: The longest continuous increasing subsequence is , its length is 1.
Note: Length of the array will not exceed 10,000.

class Solution:
    def findLengthOfLCIS(self, nums: List) -> int:
      if nums == None or len(nums) == 0:
            return 0
      count = 1
      res = 1
      for i in range(1, len(nums)):
            if nums > nums:
                count += 1
            else:
                count = 1
            res = max(res, count)
      return res
页: [1]
查看完整版本: Leetcode 674. Longest Continuous Increasing Subsequence