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

贪心思想,每一个点移动到下一个点的时间,由其横纵坐标中较大的决定。

posted on 2019-11-24 12:24  Sempron2800+  阅读(178)  评论(0编辑  收藏  举报