Skip to content

Commit 10ba4e0

Browse files
committed
feat: add 0219 Two Sum solution
1 parent 36ffedd commit 10ba4e0

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

two-sum/hyogshin.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class Solution:
2+
def twoSum(self, nums: List[int], target: int) -> List[int]:
3+
rs = []
4+
for i in range(len(nums) - 1, -1, -1):
5+
pair = target - nums[i]
6+
if pair not in nums or i == nums.index(pair):
7+
continue
8+
idx = nums.index(pair)
9+
if pair in nums:
10+
rs.append(i)
11+
rs.append(idx)
12+
break
13+
return rs
14+

0 commit comments

Comments
 (0)