Trains the technique from
LeetCode 490The MazeThis 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 tray is given as maze, where 0 is open and 1 is a wall. A bearing starts at the cell start, given as [row, column].
A roll sends the bearing in one of the four directions along the rows or columns; it keeps going until it is stopped by a wall or by the edge of the tray, and only then may another roll be chosen. The bearing cannot be stopped part way.
Return true when some sequence of rolls leaves the bearing resting on destination, given the same way.
Example 1
A roll along the row cannot stop in the middle, so the bearing goes straight past the destination to the far end.
Example 2
Rolling right carries the bearing to the far end of the row, which is where the destination sits.
Example 3
A wall sits between the two cells, so the bearing cannot get past it at all.
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 has_path(maze: list[list[int]], start: list[int], destination: list[int]) -> bool:public boolean hasPath(int[][] maze, int[] start, int[] destination)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.