diff --git a/solution/001.Two Sum/Solution.py b/solution/001.Two Sum/Solution.py new file mode 100644 index 0000000000000..cab462c002a7b --- /dev/null +++ b/solution/001.Two Sum/Solution.py @@ -0,0 +1,14 @@ +class Solution: + def twoSum(self, nums, target): + """ + :type nums: List[int] + :type target: int + :rtype: List[int] + """ + tmp={k:v for k,v in enumerate(nums)} + for k,v in tmp.items(): + tmp0=tmp.copy() + tmp0.pop(k) + if target-v in tmp0.values(): + return [k,list(tmp0.keys())[list(tmp0.values()).index(target-v)]] + return [] \ No newline at end of file