674. Longest Continuous Increasing Subsequence
时间:2020-07-14 01:03:41
收藏:0
阅读:77
Given an unsorted array of integers, find the length of longest continuous
increasing subsequence (subarray).
找最长连续上升子序列
class Solution(object): def findLengthOfLCIS(self, nums): """ :type nums: List[int] :rtype: int """ n = len(nums) global_max = 1 if n > 0 else 0 current_max = 1 for i in range(1, len(nums), 1): if nums[i] > nums[i - 1]: current_max += 1 global_max = max(global_max, current_max) else: current_max = 1 return global_max
原文:https://www.cnblogs.com/whatyouthink/p/13296616.html
评论(0)