Skip to content

Commit dfa9b30

Browse files
committed
two_sum doc
1 parent d9fb4be commit dfa9b30

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

docs/index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
## 🔍 Code Examples
22
- [Game of life](game_of_life.md)
33
Contains an implementation of [Conway's Game of Life](https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life) cellular automation.
4+
- [Two sum](two_sum.md) ➔ Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.
5+

docs/two_sum.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
## Two sum
2+
3+
Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.
4+
5+
You may assume that each input would have exactly one solution, and you may not use the same element twice.
6+
7+
You can return the answer in any order.
8+
9+
10+
11+
### Example 1:
12+
13+
Input: nums = [2,7,11,15], target = 9
14+
Output: [0,1]
15+
Explanation: Because nums[0] + nums[1] == 9, we return [0, 1].
16+
17+
### Example 2:
18+
19+
Input: nums = [3,2,4], target = 6
20+
Output: [1,2]
21+
22+
### Example 3:
23+
24+
Input: nums = [3,3], target = 6
25+
Output: [0,1]
26+
27+
28+
### Constraints:
29+
30+
2 <= nums.length <= 104
31+
-109 <= nums[i] <= 109
32+
-109 <= target <= 109
33+
Only one valid answer exists.
34+
35+

0 commit comments

Comments
 (0)