标签:class info 最小 inf lis subarray mamicode sub solution
题目描述:
方法一:双指针 O(N)
class Solution: def minSubArrayLen(self, s: int, nums: List[int]) -> int: left = 0 res = float(‘inf‘) sum = 0 for i in range(len(nums)): sum += nums[i] while sum >= s: res = min(res,i-left+1) sum -= nums[left] left += 1 return res if res != float("inf") else 0
方法二: 二分 O(NlogN)*
标签:class info 最小 inf lis subarray mamicode sub solution
原文地址:https://www.cnblogs.com/oldby/p/11619393.html