Leetcode 1395 Solution

This article provides solution to leetcode question 1395 (minimum-time-visiting-all-points)

https://leetcode.com/problems/minimum-time-visiting-all-points

Solution

class Solution: def minTimeToVisitAllPoints(self, points: List[List[int]]) -> int: def dist(point1, point2): xdist = abs(point1[0] - point2[0]) ydist = abs(point1[1] - point2[1]) return max(xdist, ydist)
n = len(points)
if n == 1: return 0
ans = 0 for i in range(n - 1): point1 = points[i] point2 = points[i + 1] ans += dist(point1, point2) return ans