Skip to content
This repository has been archived by the owner on May 3, 2024. It is now read-only.

Commit

Permalink
leetcode: finished #167
Browse files Browse the repository at this point in the history
  • Loading branch information
xqm32 committed Feb 27, 2024
1 parent 865b2e9 commit 8c80871
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions content/leetcode/2024/2.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,34 @@ title: 2024.2
draft: false
---

# 2024.2.27

```typescript
/*
* @lc app=leetcode.cn id=167 lang=typescript
*
* [167] 两数之和 II - 输入有序数组
*/

// @lc code=start
function twoSum(numbers: number[], target: number): number[] {
let left = 0;
let right = numbers.length - 1;
while (left < right) {
const sum = numbers[left] + numbers[right];
if (sum === target) {
return [left + 1, right + 1];
} else if (sum < target) {
left++;
} else {
right--;
}
}
return [];
}
// @lc code=end
```

# 2024.2.26

```typescript
Expand Down

0 comments on commit 8c80871

Please sign in to comment.