You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
##LeetCode description of "209. Minimum Size Subarray Sum"
8
5
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.
9
6
10
-
* A**subarray** is a contiguous non-empty sequence of elements within an array.
11
-
12
-
Difficulty:**Medium**
7
+
>* A**subarray** is a contiguous non-empty sequence of elements within an array.
13
8
14
9
###[Example 1]
15
10
**Input**:`target = 7, nums = [2,3,1,2,4,3]`
@@ -29,16 +24,16 @@ Difficulty: **Medium**
29
24
**Output**:`0`
30
25
31
26
###[Constraints]
32
-
-`1 <= target <= 10 **9`
33
-
-`1 <= nums.length <=100000`
27
+
-`1 <= target <= 10^9`
28
+
-`1 <= nums.length <=10^5`
34
29
-`1 <= nums[i] <= 10000`
35
30
36
31
##Intuition
37
32
For**subarray** problems, you can consider using**Sliding Window Technique**, which is similar to the**Fast and Slow Pointers Technique**.
38
33
39
34
##Steps
40
-
* Iterate over the`nums` array, the`index` of the element is named`fastIndex`. Although inconspicuous, this is the most important logic of the_Fast and Slow Pointers Technique_. Please memorize it.
41
-
*`sum += nums[fast_index]`.
35
+
1. Iterate over the`nums` array, the`index` of the element is named`fastIndex`. Although inconspicuous, this is the most important logic of the_Fast and Slow Pointers Technique_. Please memorize it.
36
+
2.`sum += nums[fast_index]`.
42
37
```java
43
38
var minLength=Integer.MAX_VALUE;
44
39
var sum=0;
@@ -51,7 +46,7 @@ for (var fastIndex = 0; fastIndex < nums.length; fastIndex++) { // This line the
51
46
return minLength;
52
47
```
53
48
54
-
* Control of`slowIndex`:
49
+
3. Control of`slowIndex`:
55
50
```java
56
51
var minLength=Integer.MAX_VALUE;
57
52
var sum=0;
@@ -221,61 +216,3 @@ public class Solution
221
216
```
222
217
// Welcome to create a PR to complete the code of this language, thanks!
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.
4
+
##力扣“209. 长度最小的子数组”问题描述
5
+
给定一个含有`n` 个正整数的数组和一个正整数`target` 。
9
6
10
-
* A**subarray**is a contiguous non-empty sequence of elements within an array.
* Iterate over the`nums`array, the`index`of the element is named`fastIndex`. Although inconspicuous, this is the most important logic of the_Fast and Slow Pointers Technique_. Please memorize it.