Skip to content
Merged
Show file tree
Hide file tree
Changes from 37 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
4836151
contains duplicate solution
yuseok89 Jun 23, 2026
cdc00da
two sum solution
yuseok89 Jun 23, 2026
cc0a988
top k frequent elements solution
yuseok89 Jun 23, 2026
c894055
longest consecutive sequence solution
yuseok89 Jun 23, 2026
4e4e412
house robber solution
yuseok89 Jun 23, 2026
32cafb9
add newline
yuseok89 Jun 23, 2026
49ecb59
리뷰 반영
yuseok89 Jun 25, 2026
a6fcc33
리뷰 반영
yuseok89 Jun 25, 2026
38a1f67
개선 - AI assist
yuseok89 Jun 25, 2026
8bd5a32
valid anagram solution
yuseok89 Jun 29, 2026
05685ed
Merge branch 'DaleStudy:main' into main
yuseok89 Jun 29, 2026
cd23e34
climbing stairs solution
yuseok89 Jun 29, 2026
120df1f
product of array except self solution
yuseok89 Jul 1, 2026
1d4ff54
3sum solution
yuseok89 Jul 1, 2026
23142a7
validate binary search tree solution
yuseok89 Jul 1, 2026
0cb14ca
공간복잡도 업데이트
yuseok89 Jul 1, 2026
9465142
공간복잡도 업데이트
yuseok89 Jul 1, 2026
8b4a01f
Merge branch 'DaleStudy:main' into main
yuseok89 Jul 7, 2026
4b09054
validate palindrome solution
yuseok89 Jul 7, 2026
da3aad9
number of 1 bits solution
yuseok89 Jul 7, 2026
5c4d5fb
combination sum solution
yuseok89 Jul 7, 2026
03f3f1a
decode ways solution
yuseok89 Jul 7, 2026
d8d5ea4
maximum subarray solution
yuseok89 Jul 7, 2026
1f003e2
복잡도 업데이트
yuseok89 Jul 7, 2026
a022d10
재귀 로직 개선
yuseok89 Jul 9, 2026
b8248c4
maximum subarray 풀이 개선
yuseok89 Jul 9, 2026
51c1012
valid palindrome 풀이 개선
yuseok89 Jul 9, 2026
65431c0
maximum subarray 풀이 개선
yuseok89 Jul 9, 2026
e514ab2
Merge branch 'DaleStudy:main' into main
yuseok89 Jul 12, 2026
194db1c
merge two sorted lists solution
yuseok89 Jul 12, 2026
419dfc5
merge two sorted lists solution 리뷰 반영
yuseok89 Jul 14, 2026
af586d8
maximum depth of binary tree solution
yuseok89 Jul 14, 2026
e2f0e02
find minimum in rotated sorted array solution
yuseok89 Jul 14, 2026
41107c5
word search solution
yuseok89 Jul 14, 2026
37ecdd8
coin change solution
yuseok89 Jul 15, 2026
fc56573
시간 공간 복잡도 업데이트
yuseok89 Jul 15, 2026
350342d
사전 필터링
yuseok89 Jul 16, 2026
0a99924
코드 개선
yuseok89 Jul 17, 2026
2f86595
Apply suggestion from @parkhojeong
yuseok89 Jul 18, 2026
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
24 changes: 24 additions & 0 deletions coin-change/yuseok89.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.

저는 코인이 양수값만 있어서 DP만 했었는데 BFS로 해도 충분히 가능하겠네요!

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.

bfs 방식으로 풀어주셨네요. dict 이용해서 필요한 공간만 사용하는 것도 신경쓰셔서 푸신 거 같네요.

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.

🏷️ 알고리즘 패턴 분석

  • 패턴: Breadth-First Search, Hash Map / Hash Set
  • 설명: 코인 합을 목표 금액으로 도달하는 최단 경로를 BFS로 탐색하고, 방문 여부를 해시 맵으로 관리하여 중복 방문을 피합니다.

📊 시간/공간 복잡도 분석

유저 분석 실제 분석 결과
Time O(amount * len(coins)) O(amount * len(coins))
Space O(amount) O(amount)

피드백: 큐를 이용해 현재 포함된 합에 도달한 최소 동전 수를 업데이트한다. 각 합은 한 번만 방문하므로 전체 시간은 금액 범위와 동전 종류에 비례한다.

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# TC: O(amount * len(coins))
# SC: O(amount)
class Solution:
def coinChange(self, coins: List[int], amount: int) -> int:

from collections import deque

v = {0: 0}
q = deque([0])

while q and amount not in v:

cur = q.popleft()

for coin in coins:

if cur + coin > amount or cur + coin in v:
continue

v[cur + coin] = v[cur] + 1
q.append(cur + coin)

return -1 if amount not in v else v[amount]

20 changes: 20 additions & 0 deletions find-minimum-in-rotated-sorted-array/yuseok89.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.

저는 while loop 안에 복잡한 연산 들어가는거 별로라 최대한 간단하게 했는데, 이렇게 하시면 얼리 리턴이 가능해서 좋네요!

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.

🏷️ 알고리즘 패턴 분석

  • 패턴: Binary Search
  • 설명: 로테이션된 정렬 배열에서 최소값을 이분 탐색으로 찾는 문제로, 중간값과 양 끝 값의 관계를 이용해 탐색 구간을 절반으로 축소한다. 조건 분기에 따라 최솟값 위치를 판단하거나 구간을 좁혀 답을 얻는다.

📊 시간/공간 복잡도 분석

유저 분석 실제 분석 결과
Time O(logN) O(log n)
Space O(1) O(1)

피드백: 범위를 반으로 나누며 조건에 따라 최소값의 위치를 좁혀간다.

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# TC: O(logN)
# SC: O(1)
class Solution:
def findMin(self, nums: List[int]) -> int:
low = 0
high = len(nums) - 1

while low < high - 1:
mid = (low + high) // 2

if nums[low] < nums[mid] < nums[high]:
return nums[low]

if nums[low] > nums[mid]:
high = mid
else:
low = mid

Comment thread
yuseok89 marked this conversation as resolved.
return min(nums[low], nums[high])

19 changes: 19 additions & 0 deletions maximum-depth-of-binary-tree/yuseok89.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.

아주 개인적인 생각인데, rec을 쓰지 않고 maxDepth 자체를 재귀로 하면 좀 코드가 간단해지지 않을까요?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

그러네요. 문제 풀 당시에는 바로 생각을 못했었네요.
리뷰 감사합니다.

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.

🏷️ 알고리즘 패턴 분석

  • 패턴: Depth-First Search, Binary Search
  • 설명: 해당 코드는 재귀적인 트리 탐색으로 각 노드의 좌우 자식 깊이를 비교하여 최대 깊이를 구하므로 DFS 패턴에 속합니다. 트리의 구조를 순회하며 연결된 노드 방문을 반복하는 방식입니다.

📊 시간/공간 복잡도 분석

유저 분석 실제 분석 결과
Time O(N) O(n)
Space O(H) O(h)

피드백: 각 노드를 한 번씩 방문하고 호출 스택의 깊이는 트리의 높이에 비례한다.

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# TC: O(N)
# SC: O(H)
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# self.right = right
class Solution:
def maxDepth(self, root: Optional[TreeNode]) -> int:

def rec(node, height):
if not node:
return height

return max(rec(node.left, height + 1), rec(node.right, height + 1))

return rec(root, 0)

26 changes: 26 additions & 0 deletions merge-two-sorted-lists/yuseok89.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.

이거 2개 비교하는 부분 끝나고 리스트 두개중에 한개 순회 다 끝난 상태에서는 나머지 남은 리스트는 그냥 뒤에 통째로 붙혀주는게 더 좋더라구요!
그니까 while 말구 단일 if문으로 처리가 가능해서 이게 훨씬 깔끔하고 좋은것 같았어요
파이썬의 or가 어떻게 단축평가를 하는지 고려하면 더욱 줄일수도 있구요!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

의견 감사합니다.
굳이 더 순회 할 필요 없었네요.
파이썬 or 도 좀 더 살펴보겠습니다.

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.

🏷️ 알고리즘 패턴 분석

  • 패턴: Two Pointers, Merge
  • 설명: 두 연결 리스트를 병합하기 위해 두 포인터(list1, list2)로 원소를 차례로 비교하며 새로운 리스트를 만들어가는 패턴입니다. 시간 복잡도 O(N+M), 추가 공간은 상수로 구현됩니다.

📊 시간/공간 복잡도 분석

유저 분석 실제 분석 결과
Time O(N+M) O(n + m)
Space O(1) O(1)

피드백: 두 리스트를 동시에 순회하며 더 작은 노드를 연결한다.

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# TC: O(N+M)
# SC: O(1)
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next
class Solution:
def mergeTwoLists(self, list1: Optional[ListNode], list2: Optional[ListNode]) -> Optional[ListNode]:

ret = ListNode()
cur = ret
Comment on lines +11 to +12

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.

ret은 무슨 약자일까요?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

return value 약자로 썼는데,
다음엔 좀 더 가독성 있게 작성해보겠습니다.


while list1 and list2:
if list1.val < list2.val:
cur.next = list1
list1 = list1.next
else:
cur.next = list2
list2 = list2.next
cur = cur.next

cur.next = list1 if list1 else list2

return ret.next

37 changes: 37 additions & 0 deletions word-search/yuseok89.py

@alphaorderly alphaorderly Jul 15, 2026

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.

이거 회원님 답안은 3000ms 가량 걸리는데
백트래킹을 유지한 상태에서

  1. 어차피 답이 안되는것 미리 쳐내기
  2. 좀 더 효율적으로 탐색하기

이 두가지만 추가해도 leetcode 실행속도상 0ms까지 도달할수 있어요!
꽤나 흥미롭더라구요, 저는 하나하나 직접 추가해가면서 성능 튜닝 했었네요

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.

Image

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.

백트래킹에서 탐색공간을 프루닝하는건 좋은 공부가 될것 같습니다!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

리뷰 감사합니다.
미리 쳐내기는 바로 반영되어도 좋을 것 같아요.
효율적으로 탐색하는 것은 작성하신 코드를 보니 뒤집어서 탐색하는 것을 말씀하시는 것 같은데,
뒤집는 쪽이 느려지는 경우도 만들어지긴 해서, 어느 경우에나 효율적이라고 보기는 어려운 것 같았어요.
이 문제 테스트셋에는 정말 잘 맞는 것 같습니다.

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.

맞습니다! 빈도 기반으로 뒤집었는데, 해당 문제를 어떻게 하면 조금이라도 빨리 풀수 있을까에만 초점을 맞춘 코드이긴 합니다!

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.

🏷️ 알고리즘 패턴 분석

  • 패턴: Depth-First Search, Backtracking
  • 설명: 코드는 DFS를 이용해 2D 보드에서 단어를 순서대로 탐색하며, 방문한 셀을 표시 후 되돌려 놓는 백트래킹 방식으로 부분해를 찾는다. 사전 조건 검사와 4방향 탐색이 핵심 포인트이다.

📊 시간/공간 복잡도 분석

유저 분석 실제 분석 결과
Time O(NM4^L) O(해당 문자열의 탐색 공간)
Space O(L) O(n * m)

피드백: 입력 글자 빈도 검사를 먼저 수행해 실패를 조기에 핸들링한다. DFS로 인접 칸을 탐색한다.

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# TC: O(N*M*4^L)
# SC: O(L)
class Solution:
def exist(self, board: List[List[str]], word: str) -> bool:

n = len(board)
m = len(board[0])

board_counter = Counter(board[r][c] for r in range(n) for c in range(m))
word_counter = Counter(word)

for c, cnt in word_counter.items():
if board_counter[c] < cnt:
return False
Comment on lines +9 to +14

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.

빈도 이용해서 최적화하신 거 좋은 거 같습니다. 이걸 rec 함수에서도 사용하면 좀 더 최적화가 가능할 거 같네요.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

rec 함수에서 어떻게 활용할 수 있을까요?

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.

제가 잘못 생각헀네요. 초기에 한 번 사용하면 이후 과정에선 불필요하네요!


def rec(row, col, idx):
if idx == len(word):
return True

if row < 0 or row >= n or col < 0 or col >= m or board[row][col] != word[idx]:
return False

board[row][col] = None

ret = rec(row + 1, col, idx + 1) or rec(row - 1, col, idx + 1) or rec(row, col + 1, idx + 1) or rec(row, col - 1, idx + 1)

board[row][col] = word[idx]
Comment on lines +23 to +27

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.

None으로 할당했다가 word[idx]로 복원하는거 좋은 거 같습니다!


return ret

for row in range(0, n):
for col in range(0, m):
if board[row][col] == word[0] and rec(row, col, 0):
return True

return False

Loading