Skip to content

Commit 990065d

Browse files
committed
Add solutions
1 parent ed7e3aa commit 990065d

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

two-sum/hypoxisaurea.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
from typing import List
22

33
class Solution:
4+
def twoSum(self, nums: List[int], target: int) -> List[int]:
5+
for i in range(len(nums)):
6+
diff = target - nums[i]
7+
8+
for j in range(i+1, len(nums)):
9+
if nums[j] == diff:
10+
return [i, j]
11+
12+
raise ValueError('No answer')
13+
14+
15+
class Solution2:
416
def twoSum(self, nums: List[int], target: int) -> List[int]:
517
lookup = {}
618

0 commit comments

Comments
 (0)