diff --git a/problems/0209.长度最小的子数组.md b/problems/0209.长度最小的子数组.md index fbef7692..160f93bb 100644 --- a/problems/0209.长度最小的子数组.md +++ b/problems/0209.长度最小的子数组.md @@ -162,8 +162,27 @@ class Solution: index += 1 return 0 if res==float("inf") else res ``` - - +```python3 +#滑动窗口 +class Solution: + def minSubArrayLen(self, target: int, nums: List[int]) -> int: + if nums is None or len(nums)==0: + return 0 + lenf=len(nums)+1 + total=0 + i=j=0 + while (j=target): + lenf=min(lenf,j-i) + total=total-nums[i] + i+=1 + if lenf==len(nums)+1: + return 0 + else: + return lenf +``` Go: ```go func minSubArrayLen(target int, nums []int) int {