You are given n integer points points[i] = [xi, yi] on a 2D plane. Return the minimum time in seconds to visit all of them in the given order. Each second you can move one unit vertically, one unit horizontally, or one unit diagonally (one unit in both directions at once). Passing through a later point early does not count as visiting it.
You are given n integer points points[i] = [xi, yi] on a 2D plane. Return the minimum time in seconds to visit all of them in the given order. Each second you can move one unit vertically, one unit horizontally, or one unit diagonally (one unit in both directions at once). Passing through a later point early does not count as visiting it.
Example 1:
Input: {"points":[[1,1],[3,4],[-1,0]]}
Output: 7
Constraints:
points.length==n
1≤n≤100
points[i].length==2
−1000≤points[i][0],points[i][1]≤1000
Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result
Run code to see results.
Input
arr ={"points":[[1,1],[3,4],[-1,0]]}
Visit 3 points in order. Each second moves one unit sideways, up or down, or one unit diagonally.
the plane (purple = diagonal steps, blue = straight steps)