Skip to content

Commit 31ad063

Browse files
committed
WEEK 01: two sum solution
1 parent 315bcb6 commit 31ad063

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

two-sum/mandel-17.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from typing import List
2+
3+
class Solution:
4+
def twoSum(self, nums: List[int], target: int) -> List[int]:
5+
for i, v in enumerate(nums):
6+
second_value = target - v
7+
8+
if second_value in nums[i+1:]:
9+
return [i, nums[i+1:].index(second_value) + i+1]

0 commit comments

Comments
 (0)