Skip to content

Commit 0b57a93

Browse files
committed
feat: solve new question
1 parent 5e6d06d commit 0b57a93

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

two-sum-ii-input-array-is-sorted/main_with_two_pointer.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ var twoSum = function(numbers, target) {
1010

1111
while (l < r) {
1212
let calculation = numbers[l] + numbers[r];
13-
if (calculation == target) {
13+
if (calculation === target) {
1414
ret.push(l+1, r+1);
1515
return ret;
16-
} else if (calculation > target) {
17-
r = r - 1;
16+
} else if (calculation < target) {
17+
l++;
1818
} else {
19-
l = l + 1;
19+
r--;
2020
}
2121
}
2222

0 commit comments

Comments
 (0)