We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents e2e7e55 + b10f7ed commit 05df5a1Copy full SHA for 05df5a1
problems/0209.长度最小的子数组.md
@@ -179,8 +179,27 @@ class Solution:
179
index += 1
180
return 0 if res==float("inf") else res
181
```
182
-
183
+```python3
+#滑动窗口
184
+class Solution:
185
+ def minSubArrayLen(self, target: int, nums: List[int]) -> int:
186
+ if nums is None or len(nums)==0:
187
+ return 0
188
+ lenf=len(nums)+1
189
+ total=0
190
+ i=j=0
191
+ while (j<len(nums)):
192
+ total=total+nums[j]
193
+ j+=1
194
+ while (total>=target):
195
+ lenf=min(lenf,j-i)
196
+ total=total-nums[i]
197
+ i+=1
198
+ if lenf==len(nums)+1:
199
200
+ else:
201
+ return lenf
202
+```
203
Go:
204
```go
205
func minSubArrayLen(target int, nums []int) int {
0 commit comments