Skip to content
Open
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
3 changes: 3 additions & 0 deletions contains-duplicate/Yiseull.py

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🏷️ 알고리즘 패턴 분석

  • 패턴: Hash Map / Hash Set
  • 설명: 집합(set) 사용으로 중복 여부를 확인하는 방식으로, 해시를 이용한 빠른 중복 탐지가 핵심 패턴입니다.

📊 시간/공간 복잡도 분석

복잡도
Time O(n)
Space O(n)

피드백: 정수 배열의 중복 여부를 빠르게 확인하기 위해 모든 원소를 집합에 담아 크기 비교를 수행합니다.

개선 제안: 현재 구현이 적절해 보입니다.

💡 풀이에 시간/공간 복잡도를 주석으로 남겨보세요!

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Solution:
def containsDuplicate(self, nums: List[int]) -> bool:
return len(nums) != len(set(nums))
16 changes: 16 additions & 0 deletions longest-consecutive-sequence/Yiseull.py

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🏷️ 알고리즘 패턴 분석

  • 패턴: Hash Map / Hash Set, Two Pointers
  • 설명: 집합을 이용해 연속 부분 수열의 시작점을 찾고, 각 시작점에서 연속 길이를 확장해 최장 길이를 구하는 방식으로 구현되어 있습니다. 해시 셋으로 중복 제거 및 O(n) 평균 시간 복잡도를 확보합니다.

📊 시간/공간 복잡도 분석

복잡도
Time O(n)
Space O(n)

피드백: 각 수에 대해 시작점 여부를 확인하고, 시작점인 경우에만 연속 길이를 확장합니다.

개선 제안: 현재 구현이 적절해 보입니다.

💡 풀이에 시간/공간 복잡도를 주석으로 남겨보세요!

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class Solution:
def longestConsecutive(self, nums: List[int]) -> int:
answer = 0
numsSet = set(nums)
for num in numsSet:
if num - 1 in numsSet:
continue

size = 1
while num + 1 in numsSet:
size += 1
num += 1

answer = max(answer, size)

return answer
30 changes: 30 additions & 0 deletions top-k-frequent-elements/Yiseull.py

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🏷️ 알고리즘 패턴 분석

  • 패턴: Hash Map / Hash Set, Heap / Priority Queue
  • 설명: 코드에서 각 숫자의 빈도수를 해시 맵에 저장하고, 빈도에 기반해 최대 k개를 뽑기 위해 힙(우선순위 큐)을 사용합니다. 이로써 두 가지 패턴이 모두 적용됩니다.

📊 시간/공간 복잡도 분석

복잡도
Time O(n log k)
Space O(n)

피드백: 해시맵으로 빈도수를 구하고 최소 힙을 이용해 k개를 유지하는 방식으로 동작합니다.

개선 제안: 현재 구현이 적절해 보입니다.

💡 풀이에 시간/공간 복잡도를 주석으로 남겨보세요!

Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from collections import Counter

class Solution:
def topKFrequent(self, nums: List[int], k: int) -> List[int]:
# return [key for key, counter in Counter(nums).most_common(k)]

# counter = {}
# for num in nums:
# if num in counter:
# counter[num] += 1
# continue
# counter[num] = 1
#
# return [key for key, counter in sorted(counter.items(), key=lambda x: -x[1])[0:k]]

counter = {}
for num in nums:
if num in counter:
counter[num] += 1
continue
counter[num] = 1

heap = [(-v, k) for k, v in counter.items()]
heapify(heap)

answer = []
for _ in range(k):
answer.append(heappop(heap)[1])

return answer
7 changes: 7 additions & 0 deletions two-sum/Yiseull.py

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🏷️ 알고리즘 패턴 분석

  • 패턴: Hash Map / Hash Set, Two Pointers
  • 설명: 주어진 코드는 한 번의 순회로 각 숫자의 필요 보수를 해시 맵에 저장하고, 필요한 값이 이미 맵에 있을 때를 찾아 두 인덱스를 반환한다. 즉 해시 맵을 이용한 탐색 기반 패턴과 두 수의 합 문제의 일반적 해결법을 적용한다.

📊 시간/공간 복잡도 분석

복잡도
Time O(n)
Space O(n)

피드백: 가치-인덱스 매핑을 이용해 목표 차이를 가진 숫자를 찾습니다.

개선 제안: 현재 구현이 적절해 보입니다.

💡 풀이에 시간/공간 복잡도를 주석으로 남겨보세요!

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class Solution:
def twoSum(self, nums: List[int], target: int) -> List[int]:
numMap = {}
for i, num in enumerate(nums):
if target - num in numMap:
return [numMap[target- num], i]
numMap[num] = i
Loading