1 class Solution: 2 def minTimeToVisitAllPoints(self, points: List[List[int]]) -> int: 3 n = len(points) 4 sec = 0 5 for i in range(n-1): 6 cp = points[i] 7 np = points[i+1] 8 sec += max(abs(cp[0]-np[0]),abs(cp[1]-np[1])) 9 return sec
贪心思想,每一个点移动到下一个点的时间,由其横纵坐标中较大的决定。