Dashboard
LC #209
Minimum Size Subarray Sum
Pattern · ?AmazonGoogleMeta
Problem
Given an array of positive integers and a target, find the minimal length of a subarray whose sum is ≥ target.
Constraints
- 1 ≤ n ≤ 10⁵
- 1 ≤ target ≤ 10⁹
- 1 ≤ nums[i] ≤ 10⁴
Example
- Input
- target = 7, nums = [2, 3, 1, 2, 4, 3]
- Output
- 2
- Why
- [4, 3] has sum ≥ 7 with minimum length 2
Spot the pattern
Which pattern cracks it?
Hints
One at a time