Hello,
I was doing the problem 'Minimum Size Subarray Sum' under 'Two-Pointer Technique'. Instructions are as follows:
- "Given an array of positive integers nums and a positive integer target, return the minimal length of a contiguous subarray [numsl, numsl+1, ..., numsr-1, numsr] of which the sum is greater than or equal to target. If there is no such subarray, return 0 instead."
Now once I submitted my answer, one of the test inputs were as follows:
- nums = [12,28,83,4,25,26,25,2,25,25,25,12]
- target = 213
- expected output = 8
However, this is wrong. The expected output should be 7... the maximum 7 numbers in nums still >= target:
- sorted nums: [2, 4, 12, 12, 25, 25, 25, 25, 25, 26, 28, 83]
- sum(25,25,25,25,26,28,83) == 237 >= target
Am I missing something?
Cheers,
Ben