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
4 changes: 4 additions & 0 deletions contains-duplicate/ayleeee.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class Solution:
def containsDuplicate(self, nums: List[int]) -> bool:
return len(set(nums))!=len(nums)

11 changes: 11 additions & 0 deletions top-k-frequent-elements/ayleeee.py
Copy link
Contributor

Choose a reason for hiding this comment

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

bucket sort을 활용한다면 더욱 효율적일 것 같습니다.

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class Solution:
def topKFrequent(self, nums: List[int], k: int) -> List[int]:
dict_map = {}
for a in nums:
if a in dict_map:
dict_map[a] += 1
else:
dict_map[a] = 1
lst = sorted(dict_map.items(), key=lambda x: x[1], reverse=True) # 공백 수정
return [item[0] for item in lst[0:k]]

6 changes: 6 additions & 0 deletions two-sum/ayleeee.py
Copy link
Contributor

Choose a reason for hiding this comment

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

HashMap과 보완값(complement)을 활용하면 효율적일 것 같습니다

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class Solution:
def twoSum(self, nums: List[int], target: int) -> List[int]:
for a in range(len(nums)):
for b in range(a+1,len(nums)):
if nums[a]+nums[b]==target:
return [a,b]