Skip to content

Commit d5396b9

Browse files
committed
Merge branch 'master' of github.com:yanglbme/leetcode
2 parents 0251f4f + bd55c2b commit d5396b9

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)