FAANG · LeetCode #209
Minimum Size Subarray Sum — three-stage drill
1The ProblemMedium
Minimum Size Subarray Sum
Shortest contiguous subarray whose sum is at least the target.
Examples
[2,3,1,2,4,3], t=7→ 2[1,2,3], t=7→ 0
constraintAll numbers are positive (1 ≤ nums[i]).
2The PatternTIME O(n) · SPACE O(k)
Sliding Window
A contiguous window that grows and shrinks to stay valid.
Problems using this pattern
3The SolutionRESULT → 2
Step through it
right → 0: add 2. sum = 2 < 7
Step 1 / 11
Arrow keys to navigate · escape to reset