-
Notifications
You must be signed in to change notification settings - Fork 0
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
[이지민] - 공유기 설치, 트리의 지름, 뮤탈리스트 #251
Conversation
MutableList(c + 1) { 0 } | ||
} | ||
} | ||
visited[a][b][c] = 1 |
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.
이거 하나로 값 저장이랑 방문 처리까지 판단하신게 스마트하시네요,,
} | ||
maxi.sortDescending() | ||
if (maxi.size >= 2) { | ||
result = max(result, maxi[0] + maxi[1]) |
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.
애초에 리턴을 max(두 큰 자식의 합)으로 하면 됐군여!!
|
||
fun binarySearch(n: Int, c: Int, houses: MutableList<Int>):Int { | ||
var start = 1 | ||
var end = houses.last() - houses.first() + 1 |
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.
�이진탐색 로직 맞추는게 진짜 어렵ㄹ네여 ㅠ...
val maxi = mutableListOf<Int>(0) | ||
tree[node].forEach { | ||
val newNode = it.first | ||
maxi.add(it.second + dfs(newNode, tree)) | ||
} | ||
maxi.sortDescending() | ||
if (maxi.size >= 2) { | ||
result = max(result, maxi[0] + maxi[1]) | ||
} | ||
|
||
return maxi.first() |
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.
maxi 에 0 처리가 너무 좋았습니다! 굳굳👍
repeat(3 - healthes.size) { | ||
healthes.add(0) | ||
} | ||
|
||
bfs(healthes[0], healthes[1], healthes[2]) |
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.
크으~ 추가 0 을 처리하는 로직 좋네요👍
val visited = MutableList(a + 1) { | ||
MutableList(b + 1) { | ||
MutableList(c + 1) { 0 } | ||
} | ||
} | ||
visited[a][b][c] = 1 |
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.
visited
처리 설명 감사합니다! 😃
📌 from issue #248 📌
📋문제 목록📋