Skip to content

Commit 262b903

Browse files
committed
[main] two sum solution
1 parent 8a353fc commit 262b903

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

two-sum/jeongyunjae.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class Solution:
2+
3+
def twoSum(self, nums: List[int], target: int) -> List[int]:
4+
my_dict = {}
5+
6+
for i in range(len(nums)):
7+
remaining = target - nums[i]
8+
if remaining not in my_dict:
9+
my_dict[nums[i]] = i
10+
else:
11+
return [my_dict[remaining], i]

0 commit comments

Comments
 (0)