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

[장희직] - 가장 긴 증가하는 부분 수열 4, 치즈, 삼각 달팽이, 내리막 길 #267

Merged
merged 4 commits into from
May 26, 2024

Conversation

jhg3410
Copy link
Member

@jhg3410 jhg3410 commented May 25, 2024

📌 from issue #266 📌

📋문제 목록📋

�가장 긴 증가하는 부분 수열 4: ✅
치즈: ✅
삼각 달팽이: ✅
내리막 길:⛔️ 

@jhg3410 jhg3410 self-assigned this May 25, 2024
@jhg3410 jhg3410 added the 희직 label May 26, 2024
Comment on lines +39 to +41
if (dp[i] == find) {
answer.add(sequence[i])
find -= 1
Copy link
Member

Choose a reason for hiding this comment

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

오... 이렇게도 찾을 수 있군요 👍

d = (d + 1) % 3
y += dy[d]
x += dx[d]
return sum(b, [])
Copy link
Member

Choose a reason for hiding this comment

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

flatten 배워갑니다...

Copy link
Member

@soopeach soopeach left a comment

Choose a reason for hiding this comment

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

고생하셨습니다!
최고,,,라서 드릴 말씀이 없네요

Comment on lines +27 to +32
for (i in n - 1 downTo 0) {
for (j in i + 1 until n) {
if (sequence[i] >= sequence[j]) continue
dp[i] = max(dp[i], dp[j] + 1)
}
}
Copy link
Member

Choose a reason for hiding this comment

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

시작부터 뒤에서 탐색하는 방법도 있군요..!



fun findAnswer(): Int {
for (i in n - 1 downTo 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

오?? 바깥쪽 i가 역순이어도 dp가 되는군요..??

Copy link
Member Author

Choose a reason for hiding this comment

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

넵넵 뒤에서부터 탐색해도 됩니다!
ㅋㅋㅋ 저도 다른 분들 풀이 보고 앞이어도 되는군요? 했슴다 ㅋㅋ

d = (d + 1) % 3
y += dy[d]
x += dx[d]
return sum(b, [])
Copy link
Contributor

Choose a reason for hiding this comment

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

헐..미쳣네요 이게 flatten이라니..

Comment on lines +31 to +44
# for i in range(cnt):
# if i != 0: input_idx += i + (nest + nest)
# answer_list[input_idx] = input_number
# input_number += 1
# # _
# for i in range(cnt - 1):
# input_idx += 1
# answer_list[input_idx] = input_number
# input_number += 1
# # \
# for i in range(cnt - 2):
# input_idx -= cnt - i + (nest + nest)
# answer_list[input_idx] = input_number
# input_number += 1
Copy link
Contributor

Choose a reason for hiding this comment

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

헉 근데 이 풀이도 인덱스 계산이 복잡한 와중에 통일성이 있게 계산하셨네요 ㄷㄷ..

Copy link
Member Author

Choose a reason for hiding this comment

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

쉽지 않았,,,😀
병희님 풀이도 배열 중간에 숫자 넣는 게 어려웠을 것 같은데👍

Comment on lines +8 to +19
while num <= (n + 1) * n // 2:
b[y][x] = num
ny = y + dy[d]
nx = x + dx[d]
num += 1
if 0 <= ny < n and 0 <= nx <= ny and b[ny][nx] == 0:
y, x = ny, nx
else:
d = (d + 1) % 3
y += dy[d]
x += dx[d]
return sum(b, [])
Copy link
Member

Choose a reason for hiding this comment

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

로직이 굉장히 깔끔하네유 👍 👍

@jhg3410 jhg3410 merged commit 05cb14b into main May 26, 2024
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