Minimum Size Subarray Sum



input
11
[1,2,3,4,5]
expected 3
How this is possible. I guess for this out put it should return 0 because
2+4+5 =11, 1+2+3+5 =11def minSubArrayLen(self, target_sum, a): """ :type s: int :type nums: List[int] :rtype: int """ found = False if a == []: return 0 sum = p1 = 0 min_sub_a = len(a)1 for i in range(len(a)): sum = sum + a[i] while sum >= target_sum: sum = a[p1] p1 += 1 if sum == target_sum: found = True min_sub_a = min(min_sub_a, len(a[p1:i+1])) if found == True: return min_sub_a else: return 0

@dharpatel Problem statement is to look for sums greater than target value, not equal. [3,4,5] is 12 which is greater than 11 and thus the minimum length is 3.