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

[장희직] 표현 가능한 이진트리, 절댓값 힙, 치즈, 치킨 배달 #113

Merged
merged 9 commits into from
Mar 12, 2023

Conversation

jhg3410
Copy link
Member

@jhg3410 jhg3410 commented Mar 11, 2023

📌 from issue #111 📌

📋문제 목록📋

표현 가능한 이진트리: ✅
절댓값 힙: ✅
치즈: ⛔️
치킨 배달: ✅

📍추가로 해결한 문제📍

맥주 마시면서 걸어가기: 👍  문제 유형을 파악하는 게 관건이라 생각합니다!

@jhg3410 jhg3410 added the 희직 label Mar 11, 2023
@jhg3410 jhg3410 self-assigned this Mar 11, 2023
Comment on lines +13 to +19
if (x == 0) {
pq.poll().run {
println(this ?: 0)
}
} else {
pq.add(x)
}
Copy link
Member

Choose a reason for hiding this comment

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

구조가 이해되기 쉽고 좋네요!

Comment on lines +51 to +54
if (board[nx][ny] == 1) {
board[nx][ny] = -1
cnt++
}
Copy link
Member

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

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

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

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가 필요 없군여

Comment on lines +65 to +67
fun getHeightOfTree(n: Int): Int {
return (ln(n.toDouble()) / ln(2.0)).toInt() + 1
}
Copy link
Contributor

Choose a reason for hiding this comment

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

와 높이 구하기 대박이네유

@jhg3410 jhg3410 merged commit 0d3068a into main Mar 12, 2023
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.

4 participants