This question evaluates a candidate's ability to reason about grid-based movement and time-indexed reachability, testing competencies in algorithmic analysis, discrete geometry, and distance metrics.
A truck's position on a 2D grid is known at each second.
You are given an array positions where positions[i] = [x_i, y_i] is the truck's location at time i + 1.
Another car starts at (0, 0) at time 0. Every second, it may move one unit up, down, left, right, or stay in place.
Return whether the car can occupy the same grid cell as the truck at the same time at any point.
Example:
positions = [[1, 0], [2, 0], [2, 1]]
true
, because the car can reach
(1, 0)
at time
1
.
You should describe an efficient solution and handle edge cases carefully.