1. Code
class Solution:
def minTimeToVisitAllPoints(self, points: List[List[int]]) -> int:
'''
Diagonal movement allows coordinates to be moved with minimal movement.
Therefore, I obtain the maximum number of diagonal movements between two points.
This is the smaller of the x-coordinates or the y-coordinates.
Then add a move that cannot be made diagonally.
'''
cnt = 0
for i in range(len(points)-1):
x = abs(points[i][0]-points[i+1][0])
y = abs(points[i][1]-points[i+1][1])
min_val = min(x,y)
cnt += x+y-min_val
return cnt
2. Result
Runtime : 52 ms(93.53%), Memory usage : 14 MB(92.71%)
(Runtime can be different by a system even if it is a same code.)