-
Notifications
You must be signed in to change notification settings - Fork 126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[선재] WEEK10 Solutions #537
Conversation
* brainstorming: | ||
* preorder traverse | ||
* | ||
* n = length of root |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
혹시 length of root
은 무엇을 의미하는 것일까요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
코멘트를 써두고 제출을 안했었네요..
const dfs = (current) => { | ||
const linkedNode = graph.get(current); | ||
|
||
if (memo[current] || !linkedNode || linkedNode.length === 0) return true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이 부분은 옵셔널 체이닝을 사용하시면 조금 더 간결해질 것 같아요!
if (memo[current] || linkedNode?.length){ ... }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오 그렇네요🙌
* brainstorming: | ||
* preorder traverse | ||
* | ||
* n = length of root |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
length of root는 전체 노드의 수를 말씀하시는걸까요?
@@ -0,0 +1,43 @@ | |||
/** | |||
* @description | |||
* queue의 특성을 활용하여 풀이 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이 부분에 대해서 혹시 추가 설명을 요청드려도 될까요?
* space complexity: O(p) | ||
*/ | ||
var canFinish = function (numCourses, prerequisites) { | ||
const memo = Array.from({ length: numCourses + 1 }, () => false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
수고 많으셨습니다!
const dfs = (current) => { | ||
const linkedNode = graph.get(current); | ||
|
||
if (memo[current] || !linkedNode || linkedNode.length === 0) return true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오 그렇네요🙌
if (answer === null) { | ||
answer = lists[minIndex]; | ||
tail = answer; | ||
} else { | ||
tail.next = lists[minIndex]; | ||
tail = lists[minIndex]; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@HC-kang
매번 lists의 각 lists의 head중 가장 작은 index의 head를 바꿔주는방법이 queue의 선입선출을 연상되어서 적었습니다. 🙂
답안 제출 문제
체크 리스트
In Review
로 설정해주세요.