Skip to content

Commit 714e3ab

Browse files
authored
Create minimum-time-visiting-all-points.py
1 parent cace31e commit 714e3ab

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Time: O(n)
2+
# Space: O(1)
3+
4+
class Solution(object):
5+
def minTimeToVisitAllPoints(self, points):
6+
"""
7+
:type points: List[List[int]]
8+
:rtype: int
9+
"""
10+
return sum(max(abs(points[i+1][0] - points[i][0]),
11+
abs(points[i+1][1] - points[i][1]))
12+
for i in xrange(len(points)-1))

0 commit comments

Comments
 (0)