left
pointer to 0 and sum
to 0.nums
array with an index i
representing the end pointer of the current window.
nums[i]
to sum
.sum
is greater than or equal to target
:
ans
to be the minimum of ans
and the current subarray size i + 1 - left
.nums[left]
from sum
and increment left
.ans
was updated during the process, return ans
. Otherwise, return 0 if no such subarray was found.