From 15c4b922e18748e10e48326154a8ad9fea66477c Mon Sep 17 00:00:00 2001 From: Yatin Aggarwal Date: Mon, 7 Jul 2025 00:18:07 +0530 Subject: [PATCH] Create 1266-Minimum-Time-Visiting-All-Points --- python/1266-Minimum-Time-Visiting-All-Points | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 python/1266-Minimum-Time-Visiting-All-Points diff --git a/python/1266-Minimum-Time-Visiting-All-Points b/python/1266-Minimum-Time-Visiting-All-Points new file mode 100644 index 000000000..bcebce48a --- /dev/null +++ b/python/1266-Minimum-Time-Visiting-All-Points @@ -0,0 +1,12 @@ +class Solution: + def minTimeToVisitAllPoints(self, points: List[List[int]]) -> int: + prev = points[0] + ans = 0 + for i in range(1,len(points)): + x = abs(points[i][0]-prev[0]) + y = abs(points[i][1]-prev[1]) + + ans+=abs(x-y) + ans+= min(x,y) + prev =points[i] + return ans