Skip to content

Commit 0c1602e

Browse files
committed
two sum Solution
1 parent 6fcfd86 commit 0c1602e

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

two-sum/treeStone94.py

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

0 commit comments

Comments
 (0)