We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent cb386f8 commit 6f616b5Copy full SHA for 6f616b5
README.md
@@ -618,6 +618,8 @@ https://leetcode.cn/problems/NYBBNL/
618
619
https://leetcode.cn/problems/increasing-order-search-tree/
620
621
+https://leetcode.cn/problems/two-sum-ii-input-array-is-sorted/
622
+
623
#### 安装教程
624
625
1. 安装`deno`
two-sum-ii-input-array-is-sorted/index.ts
@@ -0,0 +1,17 @@
1
+export default function twoSum(numbers: number[], target: number): number[] {
2
+ let left = 0;
3
+ let right = numbers.length - 1;
4
5
+ while (right - left >= 1) {
6
+ const sum = numbers[left] + numbers[right];
7
8
+ if (sum === target) {
9
+ return [left + 1, right + 1];
10
+ } else if (sum < target) {
11
+ left++;
12
+ } else {
13
+ right--;
14
+ }
15
16
+ return [-1, -1];
17
+}
0 commit comments