-
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
[이지민] 로봇 청소기, 보물섬, 센서, 합분해 #100
Conversation
fun dfs(x: Int, y: Int, d: Int) { | ||
rooms[x][y] = -1 | ||
var direction = -1 | ||
for (i in 3 downTo 0) { |
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.
와 down To 너무 좋네요!!
val subQueue = mutableListOf<Pair<Int, Int>>() | ||
queue.forEach{ num -> | ||
for (i in 0 until 4) { | ||
if(map[num.first + dx[i]][num.second + dy[i]] == "L") { | ||
subQueue.add(Pair(num.first + dx[i], num.second + dy[i])) | ||
map[num.first + dx[i]][num.second + dy[i]] = "W" | ||
} | ||
} | ||
} | ||
queue.clear() | ||
queue = subQueue.toMutableList() | ||
subQueue.clear() | ||
|
||
sum += 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.
풀이가 직관적으로 이해가 딱 됐습니다!! 구현력 대박입니다 이렇게 하면 L을 W으로 바꿔주면서 탐색해도 되는군여
println(result) | ||
} | ||
|
||
fun dfs(x: Int, y: Int, d: Int) { |
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.
dfs로 구현하신 점 대단하십니다..!!
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.forEach{ num -> | ||
for (i in 0 until 4) { | ||
if(map[num.first + dx[i]][num.second + dy[i]] == "L") { | ||
subQueue.add(Pair(num.first + dx[i], num.second + dy[i])) | ||
map[num.first + dx[i]][num.second + dy[i]] = "W" | ||
} | ||
} | ||
} | ||
queue.clear() |
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.
pop으로 forEach와 clear를 묶을 수 있지 않을까요??(queue)
map[x][y] = "W" | ||
|
||
while(queue.isNotEmpty()) { | ||
val subQueue = mutableListOf<Pair<Int, Int>>() |
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.
오홍🧐🧐
println(result) | ||
} | ||
|
||
fun dfs(x: Int, y: Int, d: Int) { |
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 #96 📌
📋문제 목록📋