-
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, 두 큐 합 같게 만들기, 숫자고르기, 북쪽나라의 도로 #203
Conversation
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.
고생하셨습니다!!
return count | ||
} | ||
count++ | ||
if (count > 600000) break |
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.
오,,, 이걸 계산하실 줄은...
} | ||
} | ||
deque.clear() | ||
visited.fill(false) |
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.
오 fill 까먹고있었는데 감사해요..
} | ||
} | ||
println(answers.size) | ||
for(number in answers.sorted()) { |
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.
오 고차함수말고 그냥 메서드 버전도 있군요
|
||
private fun bfs(posList: List<Pos>): Int { | ||
val deque = ArrayDeque<Pos>() | ||
deque.addAll(posList) |
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.
addAll 잘쓰시네요..!
return count | ||
} | ||
count++ | ||
if (count > 600000) break |
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.
최적화 멋졌습니다👍
while (true) { | ||
now = numbers[now] | ||
if (now == i) { | ||
answers.addAll(tmp) | ||
break | ||
} | ||
if (now in tmp || now in answers) break | ||
tmp.add(now) | ||
} |
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.
while(true)하고 안에서 break처리를 항상 깔끔하게 잘 하시는 것 같아요
} | ||
} | ||
|
||
val flattenBoard = board.flatten() |
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.
잊고있던 flatten..고차함수도 자주 다양하게 써야겠어요
} | ||
} | ||
|
||
val flattenBoard = board.flatten() |
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.
flatten 으로 하는거 좋네요!!!
📌 from issue #201 📌
📋문제 목록📋