Magicsheet logo

Minimum Time Visiting All Points

Easy
82.4%
Updated 6/1/2025

Minimum Time Visiting All Points

What is this problem about?

The Minimum Time Visiting All Points problem gives you a list of 2D points that must be visited in order. You move from one point to the next, where each second you can move at most 1 unit horizontally, 1 unit vertically, or 1 unit diagonally. Find the minimum time to visit all points in the given order. This Minimum Time Visiting All Points coding problem tests geometric distance intuition using the Chebyshev distance formula.

Why is this asked in interviews?

Meta, Amazon, Google, Bloomberg, and Media.net ask this easy-level problem to test whether candidates know the Chebyshev distance metric. The minimum time to move from point A to point B in 8-directional movement is max(|dx|, |dy|) — the Chebyshev distance. The array, math, and geometry interview pattern is demonstrated cleanly here.

Algorithmic pattern used

Chebyshev distance computation. For each consecutive pair of points (p1, p2), compute dx = |p2.x - p1.x| and dy = |p2.y - p1.y|. The minimum time is max(dx, dy). Sum these values for all consecutive pairs. This works because diagonal movement covers both dimensions simultaneously, making the bottleneck the larger of the two differences.

Example explanation

Points: [[1,1], [3,4], [-1,0]].

  • (1,1) → (3,4): dx=2, dy=3. Time = max(2,3) = 3.
  • (3,4) → (-1,0): dx=4, dy=4. Time = max(4,4) = 4. Total = 3+4 = 7.

Common mistakes candidates make

  • Using Euclidean distance (straight-line distance — incorrect for 8-directional movement).
  • Using Manhattan distance |dx| + |dy| (correct for 4-directional, not 8-directional).
  • Forgetting that diagonal moves are allowed and cover both axes simultaneously.
  • Not computing absolute values for dx and dy.

Interview preparation tip

Memorize the three movement metrics: Manhattan distance (|dx| + |dy|) for 4-directional movement; Chebyshev distance (max(|dx|, |dy|)) for 8-directional movement; Euclidean distance for actual straight-line travel. The Chebyshev metric appears in grid-based games, robot navigation, and board game problems. For easy problems, the key skill is recognizing which metric applies — getting this right immediately signals strong geometric intuition to interviewers.

Similar Questions