Skip to content

Commit

Permalink
Create 1921-eliminate-maximum-number-of-monsters.kt
Browse files Browse the repository at this point in the history
  • Loading branch information
a93a authored Nov 6, 2023
1 parent f01ae18 commit cbf8bf1
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions kotlin/1921-eliminate-maximum-number-of-monsters.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class Solution {
fun eliminateMaximum(dist: IntArray, speed: IntArray): Int {
val minReach = dist.zip(speed)
.map {
Math.ceil(it.first.toDouble() / it.second.toDouble()).toInt()
}.sorted()

var res = 0
for ((minute, reachesAt) in minReach.withIndex()) {
if (minute >= reachesAt) break
res++
}

return res
}
}

0 comments on commit cbf8bf1

Please sign in to comment.