-
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
[장희직] 표현 가능한 이진트리, 절댓값 힙, 치즈, 치킨 배달 #113
Conversation
if (x == 0) { | ||
pq.poll().run { | ||
println(this ?: 0) | ||
} | ||
} else { | ||
pq.add(x) | ||
} |
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 (board[nx][ny] == 1) { | ||
board[nx][ny] = -1 | ||
cnt++ | ||
} |
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.
이걸 bfs로 돌면서 체크할 수 있다는걸 전혀 몰랐네요,,, 👍
for (i in dx.indices) { | ||
val nx = x + dx[i] | ||
val ny = y + dy[i] | ||
if ((nx !in 0 until n) or (ny !in 0 until m)) continue |
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.
or... 배워갑니다..!!
|
||
|
||
fun getHeightOfTree(n: Int): Int { | ||
return (ln(n.toDouble()) / ln(2.0)).toInt() + 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 ny = y + dy[i] | ||
if ((nx !in 0 until n) or (ny !in 0 until m)) continue | ||
if (board[nx][ny] == 1) { | ||
board[nx][ny] = -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.
0이든 1이든 -1로 바꿔준 후에 bfs끝나고 -1을 0으로 바꿔주면 visited가 필요 없군여
fun getHeightOfTree(n: Int): Int { | ||
return (ln(n.toDouble()) / ln(2.0)).toInt() + 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.
와 높이 구하기 대박이네유
📌 from issue #111 📌
📋문제 목록📋
📍추가로 해결한 문제📍