Imagine you're a robot navigator on a 2D coordinate plane with n points marked at integer coordinates points[i] = [xi, yi]. Your mission is to visit all points in the exact order given in the array, and you need to calculate the minimum time in seconds required to complete this journey.
You have three movement options, each taking exactly 1 second:
- ๐ Move horizontally by one unit
- ๐ Move vertically by one unit
- โ๏ธ Move diagonally by one unit (equivalent to moving one unit both horizontally and vertically simultaneously)
The key insight is that diagonal movement covers the maximum distance in minimum time! You can pass through future points during your journey, but they don't count as visits until you reach them in order.
Goal: Return the minimum total time to visit all points sequentially.
Input & Output
Visualization
Time & Space Complexity
Single pass through all points, constant time per pair
Only using variables to track current calculation
Constraints
- 1 โค points.length โค 100
- points[i].length == 2
- -1000 โค points[i][0], points[i][1] โค 1000