Back to course home
0% completed
Vote For New Content
Solution: Minimum Size Subarray Sum
Problem Statement
Given a nums array containing positive integers and a positive integer target, return the minimum length of a
subarray having the sum of elements greater than or equal to target. If there is no such subarray, return 0 instead.
Examples
Example 1:
- Input:
target = 15,nums = [1, 2, 3, 4, 5, 6, 7, 8] - Expected Output:
2 - Justification: The subarray
[7, 8]has a sum of15, which is equal totargetand is the smallest possible subarray.
Example 2:
- Input:
target = 11,nums = [2, 1, 5, 2, 8]
.....
.....
.....
Like the course? Get enrolled and start learning!