Skip to content
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

Merged
merged 3 commits into from
Apr 29, 2024

Conversation

jeeminimini
Copy link
Member

@jeeminimini jeeminimini commented Apr 29, 2024

📌 from issue #248 📌

📋문제 목록📋

트리의 지름: ✅
뮤탈리스트: ⛔️
공유기 설치: ⛔️

@jeeminimini jeeminimini self-assigned this Apr 29, 2024
MutableList(c + 1) { 0 }
}
}
visited[a][b][c] = 1
Copy link
Contributor

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])
Copy link
Contributor

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

�이진탐색 로직 맞추는게 진짜 어렵ㄹ네여 ㅠ...

Comment on lines +22 to +32
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()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maxi 에 0 처리가 너무 좋았습니다! 굳굳👍

Comment on lines +13 to +17
repeat(3 - healthes.size) {
healthes.add(0)
}

bfs(healthes[0], healthes[1], healthes[2])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

크으~ 추가 0 을 처리하는 로직 좋네요👍

Comment on lines +31 to +36
val visited = MutableList(a + 1) {
MutableList(b + 1) {
MutableList(c + 1) { 0 }
}
}
visited[a][b][c] = 1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

visited 처리 설명 감사합니다! 😃

@jeeminimini jeeminimini merged commit 048bf6e into main Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants