Dashboard Temp Share Shortlinks Frames API

HTMLify

minimum-time-visiting-all-points.py
Views: 5 | Author: prakhardoneria
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
class Solution:
    def minTimeToVisitAllPoints(self, points: List[List[int]]) -> int:
        total_time = 0
        
        for i in range(len(points) - 1):
            curr_point = points[i]
            next_point = points[i + 1]
            
            dx = abs(next_point[0] - curr_point[0])
            dy = abs(next_point[1] - curr_point[1])
            
            total_time += max(dx, dy)
            
        return total_time