Ctrl K

Drone Lands on the Second

Medium
A drone flies over an endless grid and starts at cell (start_x, start_y). Every second it must move to one of its 8 neighbouring cells, sideways or diagonally. It cannot hover in place, but it may revisit cells. Return True if the drone can be at cell (end_x, end_y) after exactly seconds seconds, and False otherwise.
Example 1
start_x=1, start_y=1, end_x=4, end_y=3, seconds=5 → True

The trip takes 3 seconds (two diagonal steps and one to the right), and the drone burns the 2 spare seconds by stepping aside and coming back.

Example 2
start_x=6, start_y=6, end_x=6, end_y=6, seconds=1 → False

The drone is already there, but it has to move during that second and cannot get back in time.

Example 3
start_x=1, start_y=5, end_x=8, end_y=5, seconds=6 → False
Constraints
  • 1 ≤ start_x, start_y, end_x, end_y ≤ 10⁹
  • 0 ≤ seconds ≤ 10⁹
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsAdding Digit Lists MediumBackwards Digits in 32 Bits MediumNumber in Roman Numerals MediumDivision Without Dividing MediumMultiplying Digit Strings Medium
loading Python…
Input
start_x=1, start_y=1, end_x=4, end_y=3, seconds=5
Expected
True

Run checks the first 3 tests in your browser. Submit checks all 82 tests on the server, hidden ones included.