Conversation
sik9252
approved these changes
Feb 20, 2026
Collaborator
sik9252
left a comment
There was a problem hiding this comment.
이번 문제들 너무 잘 푸셔서 저의 지식으로는 조언드릴 부분이 하나밖에 떠오르지 않았습니다 최고 👍
|
|
||
| const sMap = new Map(); | ||
| const tMap = new Map(); | ||
|
|
Collaborator
There was a problem hiding this comment.
Map을 1개만 두고 +1, -1하면서 연산하면 코드량 감소, 메모리 절약 효과도 있을 것 같아요!
raejun92
approved these changes
Feb 20, 2026
Collaborator
raejun92
left a comment
There was a problem hiding this comment.
ValidAnagram 말고는 풀이가 다 너무 깔끔합니다!
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. Invert Binary Tree
1) 복잡도 계산
O(n)모든 노드를 한 번씩 방문하면서 left/right를 swap 한다.
2) 접근 아이디어
이 문제는 각 노드마다 왼쪽과 오른쪽 자식을 서로 바꾸고,
그 자식들에 대해서도 같은 작업을 반복하면 된다.
null이면 그대로 반환left와right를 swapleft서브트리에 대해 재귀 호출right서브트리에 대해 재귀 호출3) 회고
2. Valid Anagram
1) 복잡도 계산
O(n)문자열을 한 번 순회하며 카운트 후 비교한다.
O(k)k는 등장한 문자 종류 수2) 접근 아이디어
애너그램은 두 문자열의 각 문자 개수가 완전히 같으면 된다.
내 풀이 흐름:
falsesMap,tMap각각 문자 개수 카운트sMap을 돌면서tMap에 동일한 key/value가 있는지 확인true3) 회고
s는 +1t는 -1하면서 바로 검증하는 방식이 더 깔끔하다.
변수 하나로 충분한 다른 사람 예시도 있었다.
3. Binary Search
1) 복잡도 계산
(indexOf 사용)
O(n)O(1)(이진 탐색 구현)
O(log n)O(1)2) 접근 아이디어
정렬된 배열이라는 점이 핵심이다.
탐색 범위를 절반씩 줄이는 이진 탐색을 사용했다.
흐름:
start = 0,end = nums.length - 1start <= end동안 반복mid = floor((start + end) / 2)범위를 계속 줄이다가 못 찾으면
-1반환.3) 회고
indexOf로 풀 수 있었지만, 문제 의도는 이진 탐색 구현이었다.start <= end조건과mid업데이트가 핵심 패턴이다.4. Flood Fill
1) 복잡도 계산
O(R * C)-> 최악의 경우 이미지 다 돌 수 있다고 한다.
2) 접근 아이디어
시작점에서 상하좌우 4방향으로 퍼져나가며
기존 색(
original)과 같은 영역만 변경했다.정답을 보고 다시 풀었다.
3) 회고
original === color예외 처리가 없으면 무한 루프가 발생할 수 있다는 점이 중요하다.