Skip to content

[do-heewan] WEEK 01 Solutions #1704

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jul 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions contains-duplicate/do-heewan.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class Solution:
def containsDuplicate(self, nums: List[int]) -> bool:
sets = set(nums)

if len(nums) != len(sets):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

변수명이 sets인 것은 피하는 것이 좋습니다. set은 Python 내장 타입이므로 혼동 위험이 있어요

return True
return False

15 changes: 15 additions & 0 deletions top-k-frequent-elements/do-heewan.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class Solution(object):
def topKFrequent(self, nums, k):
count = {}
result = []

for i in nums:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

collections.Counter를 쓰면 더 간단히 처리 가능합니다

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

넵 피드백 감사합니다

if i not in count:
count[i] = 1
else:
count[i] += 1

count = sorted(count.items(), key=lambda x : x[1], reverse=True)

return [item[0] for item in count[:k]]

10 changes: 10 additions & 0 deletions two-sum/do-heewan.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class Solution(object):
def twoSum(self, nums, target):
result = []
for i in range(len(nums)-1):
for j in range(i+1, len(nums)):
if (nums[i] + nums[j] == target):
result.append(i)
result.append(j)

return result