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

[장희직] 그룹 단어 체커, 수리공 항승, 트럭 #60

Merged
merged 4 commits into from
Dec 4, 2022

Conversation

jhg3410
Copy link
Member

@jhg3410 jhg3410 commented Dec 4, 2022

📌 from issue #56 📌

📋문제 목록📋

그룹 단어 체커: ✅
수리공 항승: ✅
트럭: ✅
안녕: ❎

📝메모

안녕 문제는 왜 안 풀리지

@jhg3410 jhg3410 added the 희직 label Dec 4, 2022
fun check(word: String): Boolean {
var store = ""
word.forEach {
if (store.isEmpty()) store += it
Copy link
Member

Choose a reason for hiding this comment

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

요런 상황일 때 first(), drop(1) 을 사용해서 초기값을 store에 할당해주면 처음에만 필요한 if문을 없앨 수 있을 것 같아요!!


if (trucks.isNotEmpty() && bridge.size < w && bridge.sumOf { it.weight } < l) {
if (trucks.first() + bridge.sumOf { it.weight } <= l) {
val truck = trucks.removeFirst()
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 +14 to +24
fun check(word: String): Boolean {
var store = ""
word.forEach {
if (store.isEmpty()) store += it
if (it != store.last()) {
if (it in store) return false
store += it
}
}
return true
}
Copy link
Member

Choose a reason for hiding this comment

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

check함수로 따로 뺀게 좋네요!

val getHappy: Int,
)

fun solve() {
Copy link
Member

Choose a reason for hiding this comment

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

직접 시도하신게 대단합니다,, 👍

}

data class Truck(
val weight: Int, var time: Int
Copy link
Contributor

@bngsh bngsh Dec 4, 2022

Choose a reason for hiding this comment

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

혹시 트럭이 타임을 가지고 있으니 마지막으로 제거된 트럭의 time을 이용할 수 있다면 cnt를 없앨 수도 있지 않을까요!

@jhg3410 jhg3410 merged commit fd8b427 into main Dec 4, 2022
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