mirror of
https://gitlab.com/mfocko/LeetCode.git
synced 2024-11-09 15:59:06 +01:00
problems(kt): add “1266. Minimum Time Visiting All Points”
Signed-off-by: Matej Focko <mfocko@redhat.com>
This commit is contained in:
parent
554628a284
commit
3b9f1bd2c0
1 changed files with 8 additions and 0 deletions
8
problems/kt/minimum-time-visiting-all-points.kt
Normal file
8
problems/kt/minimum-time-visiting-all-points.kt
Normal file
|
@ -0,0 +1,8 @@
|
|||
class Solution {
|
||||
fun minTimeToVisitAllPoints(points: Array<IntArray>): Int =
|
||||
points.zip(points.drop(1)).sumOf { (a, b) ->
|
||||
val (ax, ay) = a
|
||||
val (bx, by) = b
|
||||
Math.max((ax - bx).absoluteValue, (ay - by).absoluteValue)
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue