Skip to content

Commit e5b0c87

Browse files
authored
Merge pull request #1198 from JiHyeonSu/main
[JiHyeonSu] WEEK 01 solutions
2 parents a8bda09 + 84c6eef commit e5b0c87

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

contains-duplicate/JiHyeonSu.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# 중복제거 후 길이 확인 문제
2+
# 시간복잡도 및 공간복잡도 O(n)
3+
class Solution:
4+
def containsDuplicate(self, nums: List[int]) -> bool:
5+
return len(nums) != len(set(nums))

two-sum/JiHyeonSu.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# 해시맵을 활용한 두 수의 합 구현
2+
# 시간복잡도 및 공간복잡도 O(n)
3+
class Solution:
4+
def twoSum(self, nums: List[int], target: int) -> List[int]:
5+
n_map = {}
6+
7+
for i, num in enumerate(nums):
8+
diff = target - num
9+
if diff in n_map:
10+
return [n_map[diff], i]
11+
n_map[num] = i

0 commit comments

Comments
 (0)