minSubArrayLen
Write a function called minSubArrayLen which accepts two parameters - an array of positive integers and a positive integer.
This function should return the minimal length of a contiguous subarray of which the sum is greater than or equal to the integer passed to the function. If there isn't one, return 0 instead.
minSubArrayLen([2,3,1,2,4,3], 7) // 2 -> because [4,3] is the smallest subarray
Notes
The subarray doesn't have to be a specific length. I found this curious because in the previous versions of the sliding window problem I'd have to at least know the size of the window before I started iterating.
Last updated