Minimum Time Visiting All Points
Each item points[i] = [x, y] of the list points is a spot on a grid, to be visited in the given order. In one second you may move one unit horizontally, one unit vertically, or one unit diagonally (both x and y change by 1).
Return the fewest seconds needed to visit all the points in order, starting at the first one.
Example 1
points [[1,1],[3,4],[-1,0]]
returns 7
(1,1) to (3,4) takes 3 seconds (2 diagonal, 1 up); (3,4) to (-1,0) takes 4. Total 7.
Constraints
1 <= len(points) <= 15-10 <= x, y <= 10
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More Math problems
- Money in the BankEasy
- Next PrimeEasy
- Nim GameEasy
- Perfect NumberEasy
- Perfect Square CheckEasy
- Polygon AreaEasy
- Prime FactorizationEasy
- Pythagorean TriplesEasy