Skip to content

Commit 94e78a8

Browse files
authored
Merge pull request #128 from omengye/patch-1
array index out of bounds, fix to low<n-1
2 parents 48715af + 3ad9d08 commit 94e78a8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

algorithms/cpp/3Sum/3Sum.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ vector<vector<int> > threeSum(vector<int> &num) {
8181
high--;
8282
} else{
8383
//skip the duplication
84-
while(low<n && num[low]==num[low+1]) low++;
84+
while(low<n-1 && num[low]==num[low+1]) low++;
8585
low++;
8686
}
8787
}

0 commit comments

Comments
 (0)