-
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
[장희직] - 괄호 제거, 도시 건설, 싸지방에 간 준하, 타일 채우기 #262
Conversation
if char == ')': | ||
cnt -= 1 | ||
if cnt == 0: | ||
return i + 1 + idx | ||
if char == '(': | ||
cnt += 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.
스택 같은 자료구조를 따로 쓰는 게 아니라 카운트로만 이렇게 할 수 있군요
people = [] | ||
seat = [] | ||
possible_index = [] | ||
answer = [0 for _ in range(n + 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.
애초에 컴퓨터를 일단 n개로 가정하는 것도 좋네요
dp[x] += 2 * dp[i] | ||
dp[x] += 2 | ||
|
||
print(dp[n]) |
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 parentA != parents[parentA]: | ||
parentA = parents[parentA] | ||
|
||
while parentB != parents[parentB]: | ||
parentB = parents[parentB] |
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.
바로 여기서 부모를 찾아도 괜찮군요!
heapq.heappush(seat, [end, idx]) | ||
answer[idx] += 1 | ||
|
||
count_seat = answer.index(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.
오... index 좋네요
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.
고생하셨습니다!!
|
||
count_seat = answer.index(0) | ||
print(count_seat) | ||
print(*answer[:count_seat]) |
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.
헉 이거 포인터처럼 쓰는건가요?...
- 이거요!
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.
*
<- 이걸 말씀하신 것 같은데
저건 언패킹 연산자라고 배열을 풀어주는 역할을 합니다!
참고로 코틀린에도 스프레드 연산자라고 불리는 비슷한 친구가 있어요!
val array = arrayOf(1,2,3,4)
val list = listOf(*array)
println(list)
>> [1, 2, 3, 4]
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.
오 대박... 감사합니다.
dp[x] += (dp[x - 2] * dp[2]) | ||
for i in range(2, x - 2, 2): | ||
dp[x] += 2 * dp[i] | ||
dp[x] += 2 |
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 #261 📌
📋문제 목록📋