Skip to content

Commit bd55c2b

Browse files
authored
Merge pull request doocs#2 from chakyam/master
Update solution 001 [Python3]
2 parents 4afdbd7 + da5e9b2 commit bd55c2b

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

solution/001.Two Sum/Solution.py

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class Solution:
2+
def twoSum(self, nums, target):
3+
"""
4+
:type nums: List[int]
5+
:type target: int
6+
:rtype: List[int]
7+
"""
8+
tmp={k:v for k,v in enumerate(nums)}
9+
for k,v in tmp.items():
10+
tmp0=tmp.copy()
11+
tmp0.pop(k)
12+
if target-v in tmp0.values():
13+
return [k,list(tmp0.keys())[list(tmp0.values()).index(target-v)]]
14+
return []

0 commit comments

Comments
 (0)