Skip to content

Commit 43737e5

Browse files
authored
feat: 1week (#1721)
feat: 1주차 1,2 문제
1 parent b8207ce commit 43737e5

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

contains-duplicate/chordpli.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from typing import List
2+
3+
class Solution:
4+
def containsDuplicate(self, nums: List[int]) -> bool:
5+
dic = {}
6+
7+
for num in nums:
8+
if dic.get(num):
9+
return True
10+
dic[num] = 1
11+
12+
return False

two-sum/chordpli.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from typing import List
2+
3+
class Solution:
4+
def twoSum(self, nums: List[int], target: int) -> List[int]:
5+
map = {}
6+
for i, num in enumerate(nums):
7+
complement = target - num
8+
if complement in map:
9+
return [map[complement], i]
10+
11+
map[num] = i

0 commit comments

Comments
 (0)