LeetcodeCN: 209 - Minimum Size Subarray Sum

Question: Given an array of positive integers nums and a positive integer target, return the minimal length of a subarray whose sum is greater than or equal to target. If there is no such subarray, return 0 instead.

Solution:
image

我再加多一句。如果当前的数组的和本来就不足target,那么它的任何相邻子数组都不满足要求——反之则可能。

posted @ 2023-12-20 16:17  Lemon-GPU  阅读(15)  评论(0)    收藏  举报