Trains the technique from
LeetCode 789Escape The GhostsThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A courier drone sits on the depot at (0, 0) of an unbounded integer grid. A beacon waits at beacon = [bx, by], and each entry of patrols gives the starting cell of one patrol unit.
Time advances in turns. On every turn the drone and every patrol each either hold still or step one cell north, south, east or west, all at the same moment. The patrols are told the drone's whole route in advance and move to stop it.
The drone is intercepted if a patrol shares its cell at any moment, counting the turn on which the drone first stands on the beacon: a patrol arriving there on that same turn still counts as an interception. Once the drone has stood on the beacon without being intercepted it is safe and later turns do not matter.
Return true if the drone has a route that gets it onto the beacon without being intercepted, and false otherwise. The beacon may sit on the depot, and several patrols may share a starting cell.
Example 1
The drone can step to (-1, 0) on turn 1 and onto the beacon on turn 2. Neither patrol can be standing on (-1, 0) by turn 1 or on (-1, -1) by turn 2, so nothing intercepts it.
Example 2
The patrol can walk onto the beacon and hold still there before the drone is able to stand on it, so every route the drone might take ends in an interception.
Example 3
The patrol starting at (1, 1) can be standing on the beacon on the same turn the drone first reaches it, and arriving together still counts as an interception. The patrol at (9, 9) is far away and never matters.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def can_reach_beacon(patrols: list[list[int]], beacon: list[int]) -> bool:public boolean canReachBeacon(int[][] patrols, int[] beacon)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.