Problem
Ask
Submissions

Problem: Minimum Time Visiting All Points

Easy
15 min
Explore how to determine the minimum time required to visit all points in a 2D plane following a specific order. Learn to apply efficient movement rules, including vertical, horizontal, and diagonal steps, and develop a clear approach to solving this geometric coding problem.

Statement

You are given an array of nn points with integer coordinates on a 2D plane, points, where points[i]=[xi,yi]\text{points}[i] = [x_i, y_i]. Your task is to determine the minimum time in seconds required to visit all the points in the given order.

Movement rules:

  1. In one second, you can perform any one of the following:

    1. Move vertically by one unit.

    2. Move horizontally by one unit.

    3. Move diagonally (1 unit vertically and 1 unit horizontally in 1 second).

  2. You must visit the points in the exact sequence listed in the array.

  3. You may pass through points that appear later in the order, but they will not count as visits.

Constraints:

  • points.length =n= n

  • 1n 1021 \leq n \leq 10^2

  • points[i].length =2= 2

  • 103 -10^3 \leq points[i][0], points[i][1] 103\leq 10^3

Problem
Ask
Submissions

Problem: Minimum Time Visiting All Points

Easy
15 min
Explore how to determine the minimum time required to visit all points in a 2D plane following a specific order. Learn to apply efficient movement rules, including vertical, horizontal, and diagonal steps, and develop a clear approach to solving this geometric coding problem.

Statement

You are given an array of nn points with integer coordinates on a 2D plane, points, where points[i]=[xi,yi]\text{points}[i] = [x_i, y_i]. Your task is to determine the minimum time in seconds required to visit all the points in the given order.

Movement rules:

  1. In one second, you can perform any one of the following:

    1. Move vertically by one unit.

    2. Move horizontally by one unit.

    3. Move diagonally (1 unit vertically and 1 unit horizontally in 1 second).

  2. You must visit the points in the exact sequence listed in the array.

  3. You may pass through points that appear later in the order, but they will not count as visits.

Constraints:

  • points.length =n= n

  • 1n 1021 \leq n \leq 10^2

  • points[i].length =2= 2

  • 103 -10^3 \leq points[i][0], points[i][1] 103\leq 10^3