You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The maze solver can throw an ArrayIndexOutOfBoundsException when the maze is smaller than the hard-coded destination at row 6, column 5.
For example, calling solveMazeUsingFirstStrategy with a 2x2 maze causes an exception instead of handling the maze safely. The hard-coded start and destination also make it difficult to use the solver with mazes of other sizes.
It should handle maze boundaries safely and allow the start and destination to be specified for different maze sizes.
Also, would like to improve to avoid duplicated logic.
Steps to reproduce
To update the MazeRecursion.java fix the issues
Add test to MazeRecursionTest.java
Excepted behavior
To handle maze boundaries safely and must not throw an ArrayIndexOutOfBoundsException when the maze is smaller than the hard-coded destination.
It should validate the maze and handle invalid inputs, such as null, empty.
Preserve their specified traversal order and provide shared common solving logic to eliminate code duplication.
Add testcase to validate above things to check which are covered.
Hi! I'd like to take this one. Looks like the crash comes from the hardcoded target map[6][5] — smaller mazes don't have that cell, so it throws ArrayIndexOutOfBounds. I'll derive the target position from the maze size instead and add tests with small mazes for both strategies. PR coming shortly.
Activity
Meherab-hsn commentedon Oct 31, 2026
Hi! I'd like to take this one. Looks like the crash comes from the hardcoded target map[6][5] — smaller mazes don't have that cell, so it throws ArrayIndexOutOfBounds. I'll derive the target position from the maze size instead and add tests with small mazes for both strategies. PR coming shortly.