-
-
Notifications
You must be signed in to change notification settings - Fork 245
[SeongA] WEEK08 Solution #1902
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
[SeongA] WEEK08 Solution #1902
Conversation
// Time O(V+E) | ||
// Space O(V) | ||
func cloneGraph(_ node: Node?) -> Node? { | ||
guard let node = node else { return nil } |
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.
오 이 구문이 엄청 신기하네요
node 에 값이 없으면 바로 return nil 로 한줄로 작성이 되는게 너무 신기해요😲
guard let neighbor = neighbor else { continue } | ||
|
||
if let clonedNeighbor = visited[neighbor.val] { | ||
visited[currentNode.val]!.neighbors.append(clonedNeighbor) |
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.
오 느낌표 표현이 신기하네요
seongA님 덕에 swift 문법에 신기한걸 많이 배우고 있어요ㅎㅎ 값이 있다고 치고 optional 에서 값을 빼버리다니
마치 css 에서 important (!) 같은 느낌이네요ㅎㅎ
} else { | ||
visited[neighbor.val] = Node(neighbor.val) | ||
visited[currentNode.val]!.neighbors.append(visited[neighbor.val]) | ||
queue.append(neighbor) |
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.
오.. queue와 visited 를 병행하면서 처음 cloned 한 것에 neighbors 에 cloned 를 append 하는게 인상깊네요ㅎ 👍
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.
이번주도 넘넘 고생 많으셨습니다~~ 👍
답안 제출 문제
작성자 체크 리스트
In Review
로 설정해주세요.검토자 체크 리스트
Important
본인 답안 제출 뿐만 아니라 다른 분 PR 하나 이상을 반드시 검토를 해주셔야 합니다!