Skip to content

Commit cbf8bf1

Browse files
authored
Create 1921-eliminate-maximum-number-of-monsters.kt
1 parent f01ae18 commit cbf8bf1

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
class Solution {
2+
fun eliminateMaximum(dist: IntArray, speed: IntArray): Int {
3+
val minReach = dist.zip(speed)
4+
.map {
5+
Math.ceil(it.first.toDouble() / it.second.toDouble()).toInt()
6+
}.sorted()
7+
8+
var res = 0
9+
for ((minute, reachesAt) in minReach.withIndex()) {
10+
if (minute >= reachesAt) break
11+
res++
12+
}
13+
14+
return res
15+
}
16+
}

0 commit comments

Comments
 (0)