-
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
[전현수] - 연구소 2, 두 큐 합 같게 만들기, 숫자고르기, 북쪽나라의 도로 #202
Conversation
numberList.drop(1) | ||
.forEachIndexed { unCompletedIndex, value -> | ||
linkInfoList[value].add(unCompletedIndex + 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.
밑에 줄을 기준으로 dfs 를 도신 게 좋았어요!
val first = bfs(1) | ||
println(bfs(first.index).cost) |
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.
전 무지성으로 풀었는데 수피치님 덕분에 트리의 지름이라는 개념도 알고 갑니다
|
||
} | ||
|
||
fun dfs(target: Int, current: Int, visited: BooleanArray) { |
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로 된다는게 신기하네용
copied.maxOf { row -> | ||
row.maxOf { it } |
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.
kotlin은 이런게 참 이뿌네요
fun dfs(cnt: Int, startIndex: Int, depth: Int) { | ||
if (cnt == depth) { | ||
|
||
simulate() | ||
return | ||
} | ||
|
||
for (index in startIndex until virusPositions.size) { | ||
|
||
selectedVirusIndexList.add(index) | ||
dfs(cnt + 1, index + 1, depth) | ||
selectedVirusIndexList.removeLast() | ||
|
||
} | ||
|
||
} |
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 #201 📌
📋문제 목록📋
📍추가로 해결한 문제📍
📝메모
공유하고 싶은 정보, 새롭게 알게된 것, 문제를 풀면서 발생한 에로사항 등...자유롭게!