Skip to content

Commit fc5da12

Browse files
authored
Merge pull request #1165 from JisuuungKim/main
[JisuuungKim] WEEK 1 solutions
2 parents 9abd567 + c900b53 commit fc5da12

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

contains-duplicate/JisuuungKim.py

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

two-sum/JisuuungKim.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class Solution:
2+
def twoSum(self, nums: List[int], target: int) -> List[int]:
3+
d = {}
4+
for i in range(len(nums)):
5+
cur = nums[i]
6+
x = target - cur
7+
if x in d:
8+
return [i, d[x]]
9+
else:
10+
d[cur] = i
11+
12+
# 시간복잡도 O(n)

0 commit comments

Comments
 (0)