---
# System prepended metadata

title: Leetcode 209.

---

# Leetcode 209. Minimum Size Subarray Sum

## 題解

### 滑動窗口

```python!
class Solution:
    def minSubArrayLen(self, target: int, nums: List[int]) -> int:
      n = len(nums)
      output = (10 ** 5) + 1
      left = 0
      sum = 0
      for i in range(n):
        sum += nums[i]
        while sum >= target:
          output = min(output,i+1-left)
          sum -= nums[left]
          left += 1
      return output if output != (10 ** 5) + 1 else 0
```