Skip to content

Commit c0f2079

Browse files
aQuaaQua
aQua
authored and
aQua
committed
209 finish
1 parent 6e89d31 commit c0f2079

File tree

2 files changed

+2
-5
lines changed

2 files changed

+2
-5
lines changed

Algorithms/0209.minimum-size-subarray-sum/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@ the subarray `[4,3]` has the minimal length under the problem constraint.
1111
If you have figured out the O(n) solution, try coding another solution of which the time complexity is O(n log n).
1212

1313
## 解题思路
14+
充分利用题目信息,切片中的数,全部是正数。
1415

1516
见程序注释

Algorithms/0209.minimum-size-subarray-sum/minimum-size-subarray-sum.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,6 @@ package Problem0209
22

33
func minSubArrayLen(s int, a []int) int {
44
n := len(a)
5-
6-
if n == 0 {
7-
return 0
8-
}
9-
105
res, i, j, sum := n+1, 0, 0, 0
116

127
for j < n {
@@ -22,5 +17,6 @@ func minSubArrayLen(s int, a []int) int {
2217
}
2318
}
2419

20+
// res % (n+1) 是为了处理 sum(a) < s 的情况
2521
return res % (n + 1)
2622
}

0 commit comments

Comments
 (0)