Conversation
sik9252
previously approved these changes
Feb 27, 2026
| * @return {number} | ||
| */ | ||
| MyQueue.prototype.pop = function () { | ||
| if (this.outStack.length === 0) { |
Collaborator
There was a problem hiding this comment.
pop과 peek에서 중복으로 사용되는 로직 분리해도 좋을것 같군용! 다른건 완벽!!
raejun92
reviewed
Feb 28, 2026
Collaborator
raejun92
left a comment
There was a problem hiding this comment.
BalancedBinaryTree 푸시면 다시 요청 주세요!
Collaborator
There was a problem hiding this comment.
저는 정렬이 되어 있는 줄 모르고 풀었는데 정렬되어 있는 걸 이용하면 됐군요!
Member
Author
|
4번 문제는 다시 풀어도 못풀어서 정답을 붙여뒀어요! |
raejun92
approved these changes
Mar 1, 2026
sik9252
approved these changes
Mar 2, 2026
Collaborator
sik9252
left a comment
There was a problem hiding this comment.
노트북을 안가져가서 늦게 검토했네요 죄송합니다ㅠㅠ 마지막에 확인했을때 BalancedBinaryTree 풀이만 안되어 있던걸로 기억하는데 한 번의 DFS에서 높이를 계산하면서, 불균형이면 -1을 반환해 위로 전파하는 방식인거죵??? 정석으로 잘 푸신것 같아요!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
이렇게 풀었어요
1. Linked List Cycle
1) 복잡도 계산
2) 접근 아이디어
핵심은 “값(val)이 반복되는지”가 아니라, 같은 노드(객체)를 다시 방문하는지였다.
내 풀이(Set)
다른 풀이(slow/fast)
3) 회고
처음에
head가 배열처럼 보이는 입력(예: [3,2,0,-4])로 들어오는 줄 알고 혼란스러웠다.실제로는 배열이 아니라 노드 객체(참조) head가 들어오고, 사이클 판단은
val이 아니라 노드 자체(cur)를 다시 만나는지가 핵심이었다.node.next로 따라가는 구조라는 걸 먼저 떠올리자.2. Implement Queue using Stacks
1) 복잡도 계산
push: O(1)pop/peek: outStack이 비었을 때만 inStack → outStack으로 이동 (총 이동 횟수는 각 원소당 최대 1번)2) 접근 아이디어
처음엔 “배열을 큐처럼 쓰면 되지 않나?”로 접근해서
shift/unshift나 구조분해로 앞에서 꺼내는 방법을 시도했는데,이 문제는 “스택 연산만 사용” 조건 때문에 그 방식이 틀렸다.
3) 회고
시행착오 포인트가 명확했다.
shift/unshift(앞에서 빼기/넣기)를 썼는데, 이건 스택 연산이 아니라서 문제 조건 위반이었다.이렇게 풀었어요
3. Lowest Common Ancestor of a Binary Search Tree
1) 복잡도 계산
(h = 트리의 높이, 평균적으로 log n)
(반복문 사용, 추가 메모리 없음)
2) 접근 아이디어
🔹 문제 핵심
LCA는 p와 q를 모두 자손으로 가지는 가장 아래 노드이다.
BST의 성질을 이용하면 탐색 범위를 계속 줄일 수 있다.
BST 규칙:
🔹 사고 흐름
3) 회고
처음에는 “최소/최대값을 구해서 root 위치를 바꿔야 할 것 같다”는 감은 있었지만, 그 생각을 코드로 연결하는 게 어려웠다.
핵심은:
“둘 다 왼쪽 / 둘 다 오른쪽 / 갈라지는 순간”
이 세 가지 경우만 정리하면 코드가 매우 단순해진다.
배운 점:
4. Balanced Binary Tree
1) 회고
해당 문제는 오늘 점심에 다시 풀어보려합니다. 문제 구현 자체를 못했어요 ㅠ