Skip to content
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
11 changes: 11 additions & 0 deletions contains-duplicate/HYUNAHKO.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class Solution:
def containsDuplicate(self, nums: List[int]) -> bool:
if len(nums) >= 1 and len(nums) <= 100000:
for i in range(0, len(nums)):
src = nums[i]
for j in range(i+1, len(nums)):
if src == nums[j]:
return True
return False
return False

14 changes: 14 additions & 0 deletions top-k-frequent-elements/HYUNAHKO.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
class Solution:
def topKFrequent(self, nums: List[int], k: int) -> List[int]:
value_dict = {}

for num in nums:
if num in value_dict:
value_dict[num] += 1
else:
value_dict[num] = 1

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

return [key for key, value in sorted_items[:k]]

13 changes: 13 additions & 0 deletions two-sum/HYUNAHKO.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class Solution:
def twoSum(self, nums: List[int], target: int) -> List[int]:
result = []
if len(nums) >= 2 and len(nums) <= 1e4:
Copy link
Contributor

Choose a reason for hiding this comment

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

범위 조건 안전장치를 걸어둔게 너무 좋네요!

for idx1, i in enumerate(nums):
num1 = i
for idx2 in range(idx1+1, len(nums)):
num2 = nums[idx2]
if ((num1 + num2) == target):
result.append(idx1)
result.append(idx2)
return result