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.
1 parent 87abfa1 commit b10f7edCopy full SHA for b10f7ed
problems/0209.长度最小的子数组.md
@@ -162,8 +162,27 @@ class Solution:
162
index += 1
163
return 0 if res==float("inf") else res
164
```
165
-
166
+```python3
+#滑动窗口
167
+class Solution:
168
+ def minSubArrayLen(self, target: int, nums: List[int]) -> int:
169
+ if nums is None or len(nums)==0:
170
+ return 0
171
+ lenf=len(nums)+1
172
+ total=0
173
+ i=j=0
174
+ while (j<len(nums)):
175
+ total=total+nums[j]
176
+ j+=1
177
+ while (total>=target):
178
+ lenf=min(lenf,j-i)
179
+ total=total-nums[i]
180
+ i+=1
181
+ if lenf==len(nums)+1:
182
183
+ else:
184
+ return lenf
185
+```
186
Go:
187
```go
188
func minSubArrayLen(target int, nums []int) int {
0 commit comments