cracking-the-coding-interview
cracking-the-coding-interview copied to clipboard
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index -1 out of bounds for length 3 at ctci.RobotInAGrid.getPath1(RobotInAGrid.java:49) at ctci.RobotInAGrid.getPath1(RobotInAGrid.java:56) at ctci.RobotInAGrid.getPath1(RobotInAGrid.java:56) at ctci.RobotInAGrid.getPath1(RobotInAGrid.java:56) at ctci.RobotInAGrid.getPath1(RobotInAGrid.java:41) at ctci.RobotInAGrid.main(RobotInAGrid.java:33)
Program RobotInAGrid.java Error Line 70
if (!maze[row][col] || col < 0 || row < 0) {
return false;
}
Must Be
if (col < 0 || row < 0 || !maze[row][col]) {
return false;
}