Open
Conversation
Contributor
Author
|
지난주에 참여를 못 해서 이번 주에 누락된 문제들 추가했습니다 :) |
DaleSeo
approved these changes
Feb 18, 2026
Member
DaleSeo
left a comment
There was a problem hiding this comment.
깔끔한 풀이 잘 보았습니다. 소소한 피드백을 드렸으니 참고하세요.
Comment on lines
+18
to
+19
| current_node = queue.popleft() | ||
| current_level_nodes.append(current_node.val) |
Comment on lines
+15
to
+18
| if n ==1: | ||
| return nums[0] | ||
| if n ==2: | ||
| return max(nums[0], nums[1]) |
Member
There was a problem hiding this comment.
Suggested change
| if n ==1: | |
| return nums[0] | |
| if n ==2: | |
| return max(nums[0], nums[1]) | |
| if n == 1: | |
| return nums[0] | |
| if n == 2: | |
| return max(nums[0], nums[1]) |
| return nums[0] | ||
| if n ==2: | ||
| return max(nums[0], nums[1]) | ||
| memo = {0:nums[0], 1: max(nums[0], nums[1])} |
Member
There was a problem hiding this comment.
Suggested change
| memo = {0:nums[0], 1: max(nums[0], nums[1])} | |
| memo = {0: nums[0], 1: max(nums[0], nums[1])} |
|
|
||
| class Solution: | ||
| def rob(self, nums: List[int]) -> int: | ||
| # Top Down DP |
Member
There was a problem hiding this comment.
Top-Down DP로 잘 작성되었지만, 시간이 되신다면 Bottom-Up DP로 메모리 최적화해를 시도해보셔도 좋을 것 같아요.
| # Time Complexity O(N) | ||
| def kthSmallest(self, root: Optional[TreeNode], k: int) -> int: | ||
| ans = [] | ||
| final = [0] |
Member
There was a problem hiding this comment.
이 곳에 Python의 nonlocal 키워드를 활용해보시기를 추천드립니다. 참고: https://youtu.be/LNWDLXbrZCg
Comment on lines
+31
to
+41
| while q: | ||
| curr = q.popleft() | ||
|
|
||
| # Only attempt full compare when root values match | ||
| if curr.val == subRoot.val and helper(curr, subRoot): | ||
| return True | ||
|
|
||
| if curr.left: | ||
| q.append(curr.left) | ||
| if curr.right: | ||
| q.append(curr.right) |
Member
There was a problem hiding this comment.
이 문제는 보통 재귀만으로 해결하는 경우가 많은데, 이렇게 BFS로 각 노드를 순회하며 서브트리 비교를 하는 방법이 신선하네요.
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.
답안 제출 문제
작성자 체크 리스트
In Review로 설정해주세요.검토자 체크 리스트
Important
본인 답안 제출 뿐만 아니라 다른 분 PR 하나 이상을 반드시 검토를 해주셔야 합니다!