Skip to content

Commit 444670a

Browse files
author
chenweijie
committed
array
1 parent ec46f81 commit 444670a

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

  • src/main/java/com/chen/algorithm/znn/array/offer/test57

‎src/main/java/com/chen/algorithm/znn/array/offer/test57/Solution.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public int[][] findContinuousSequence(int target) {
6666
int sum = 0;
6767
List<int[]> res = new ArrayList<>();
6868

69-
while (left <= target / 2) {
69+
while (left <= target / 2) { // 假设窗口左边界i=target/2, i+1=target/2 +1,那么i + (i+1) = target+1,即最小的窗口的元素之和就已经比target大了,所以当i>=target/2时不可能有一个窗口长度>=2的答案。 这也归因于本题的特殊要求:答案数组至少包含两个元素。 如果没有上述要求,那么在i>=target/2的范围内还存在当i == target时的结果,窗口长度==1。
7070
if (sum < target) {
7171
sum += right;
7272
right++;

0 commit comments

Comments
 (0)