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

[전현수] - 도시 건설, 괄호 제거, 싸지방에 간 준하, 타일 채우기 #263

Merged
merged 5 commits into from
May 21, 2024

Conversation

soopeach
Copy link
Member

📌 from issue #261 📌

📋문제 목록📋

도시 건설: ✅
괄호 제거: ✅
싸지방에 간 준하: ✅
타일 채우기: ⛔️

📍추가로 해결한 문제📍

추천: 👍  
비추천: 👎  
문제에 대한 간단한 코멘트를 남겨주셔도 좋을 것 같아요!

📝메모

공유하고 싶은 정보, 새롭게 알게된 것, 문제를 풀면서 발생한 에로사항 등...자유롭게!


@soopeach soopeach self-assigned this May 20, 2024
Comment on lines +52 to +75
private fun IntArray.isValid(): Boolean {
for (i in 1 until this.size) {
if (findParent(i, this) != 1) return false
}
return true
}

private fun findParent(target: Int, parentInfo: IntArray): Int {
return if (target == parentInfo[target]) target
else findParent(parentInfo[target], parentInfo)
}

private fun Int.hasSameParent(other: Int, parentInfo: IntArray): Boolean {
return findParent(this, parentInfo) == findParent(other, parentInfo)
}

private fun union(a: Int, b: Int, parentInfo: IntArray) {

val aParent = findParent(a, parentInfo)
val bParent = findParent(b, parentInfo)

if (aParent < bParent) parentInfo[bParent] = aParent
else parentInfo[aParent] = bParent
}
Copy link
Contributor

Choose a reason for hiding this comment

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

함수 정리정돈이 잘 되어있어서 인상깊었어요

Comment on lines +25 to +37
val useInfoPq = PriorityQueue<UseInfo>(
Comparator { a, b ->
a.start - b.start
}
)

val computerPq = PriorityQueue<ComInfo> { a, b ->
a.num - b.num
}

val usingInfoPq = PriorityQueue<UsingInfo> { a, b ->
a.end - b.end
}
Copy link
Contributor

Choose a reason for hiding this comment

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

pq를 여러개 쓰면 너무 복잡할 거 같았는데 오히려 그냥 시뮬레이션 같고 깔끔하네요

} else if (target[i] == ')') {
if (stack.isNotEmpty()) {
parenthesisInfoList.add(
ParenthesisInfo(stack.pop(), i)
Copy link
Contributor

Choose a reason for hiding this comment

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

짝을 찾아놓고 시작하는 게 좋앗워요👍

Comment on lines +25 to +37
val useInfoPq = PriorityQueue<UseInfo>(
Comparator { a, b ->
a.start - b.start
}
)

val computerPq = PriorityQueue<ComInfo> { a, b ->
a.num - b.num
}

val usingInfoPq = PriorityQueue<UsingInfo> { a, b ->
a.end - b.end
}
Copy link
Member

Choose a reason for hiding this comment

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

pq 3개 방식이 인상깊었습니다!

Comment on lines +46 to +52
for (i in target.indices) {
if (target[i] == '(') {
stack.add(i)
} else if (target[i] == ')') {
if (stack.isNotEmpty()) {
parenthesisInfoList.add(
ParenthesisInfo(stack.pop(), i)
Copy link
Member

Choose a reason for hiding this comment

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

미리 한 번에 다 찾아놓는 게 좋군요!!👍

@soopeach soopeach merged commit 25ad861 into main May 21, 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