-
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
[장희직] 그룹 단어 체커, 수리공 항승, 트럭 #60
Conversation
fun check(word: String): Boolean { | ||
var store = "" | ||
word.forEach { | ||
if (store.isEmpty()) store += it |
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.
요런 상황일 때 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() |
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.
큐를 사용하면 조금 더 좋지 않을까 생각해요..!!
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 | ||
} |
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.
check함수로 따로 뺀게 좋네요!
val getHappy: Int, | ||
) | ||
|
||
fun solve() { |
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.
직접 시도하신게 대단합니다,, 👍
} | ||
|
||
data class Truck( | ||
val weight: Int, var time: Int |
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.
혹시 트럭이 타임을 가지고 있으니 마지막으로 제거된 트럭의 time을 이용할 수 있다면 cnt를 없앨 수도 있지 않을까요!
📌 from issue #56 📌
📋문제 목록📋
📝메모
안녕 문제는 왜 안 풀리지