Minimum Size Subarray Sum
Given an array of positive integers nums and a positive integer target, return the minimum length of a contiguous subarray whose sum is greater than or equal…
Given an array of positive integers `nums` and a positive integer `target`, return the minimum length of a contiguous subarray whose sum is greater than or equal to `target`. Return `0` if no such subarray exists.
- `1 <= nums.length <= 10^5` - `1 <= nums[i] <= 10^4` - `1 <= target <= 10^9` - The interactive visualizer accepts at most 12 values, each from 1 through 1000, and a target from 1 through 10000; longer or larger valid inputs are execution-only.
Example 1: input nums = [2,3,1,2,4,3], target = 7; output 2. The subarray [4,3] reaches 7 and no qualifying subarray is shorter.
Example 2: input nums = [1,1,1], target = 5; output 0. Even the whole array sums to only 3, so no qualifying subarray exists.
Category: Sliding Window. Topic: sliding-window. Difficulty: Medium. Patterns: sliding-window, two-pointers.