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

[소병희] 겹치는 건 싫어, 쉬운 최단거리, 회전 초밥 #169

Merged
merged 3 commits into from
Sep 3, 2023

Conversation

bngsh
Copy link
Contributor

@bngsh bngsh commented Sep 3, 2023

📌 from issue #165 📌

📋문제 목록📋

겹치는 건 싫어: ✅
쉬운 최단거리: ✅
회전 초밥: ✅
기타리스트: ❎

@bngsh bngsh self-assigned this Sep 3, 2023
@bngsh bngsh added the 병희 label Sep 3, 2023
Comment on lines +21 to +28
while(p2 < n) {
count[nums[p2]]++
while(count[nums[p2]] > k && p1 < p2)
count[nums[p1++]]--

p2++
ans = ans.coerceAtLeast(p2 - p1)
}
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 +21 to +25
if (v.toInt() == 2) {
q.add(intArrayOf(i, j, 0))
ground[i][j] = 0
}
else if (v.toInt() == 0) {
Copy link
Member

Choose a reason for hiding this comment

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

2, 0 판단하는 부분 그냥 문자열로 검사하셨으면 사소하지만 연산이 한 번 줄었을 것 같아요!

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 +47 to +49
if (nr !in 0 until n || nc !in 0 until m) continue
if (ground[nr][nc] == 0) continue
if (ground[nr][nc] != -1) continue
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 +23 to +24
while(count[nums[p2]] > k && p1 < p2)
count[nums[p1++]]--
Copy link
Member

Choose a reason for hiding this comment

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

오호 이렇게도 할 수 있군요

repeat(n) { i ->
readLine().split(" ").forEachIndexed { j, v ->
if (v.toInt() == 2) {
q.add(intArrayOf(i, j, 0))
Copy link
Member

Choose a reason for hiding this comment

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

미리 queue에 넣는게 좋네요

Comment on lines +13 to +14
var p1 = 0
var p2 = 0
Copy link
Member

Choose a reason for hiding this comment

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

투 포인터!👍

@bngsh bngsh merged commit cedd3d5 into main Sep 3, 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