/* * @LastEditTime: 2026-01-12 23:28:12 */ classSolution { public: intminTimeToVisitAllPoints(vector<vector<int>>& points){ int ans = 0; for (int i = 1; i < points.size(); i++) { ans += max(abs(points[i][0] - points[i - 1][0]), abs(points[i][1] - points[i - 1][1])); } return ans; } };
Python
1 2 3 4 5 6 7 8 9
''' LastEditTime: 2026-01-12 23:32:26 ''' from typing importList from itertools import pairwise
classSolution: defminTimeToVisitAllPoints(self, points: List[List[int]]) -> int: returnsum(max(abs(a[0] - b[0]), abs(a[1] - b[1])) for a, b in pairwise(points))