cracking-the-coding-interview icon indicating copy to clipboard operation
cracking-the-coding-interview copied to clipboard

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException

Open mayankkt9 opened this issue 5 years ago • 0 comments

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;
}

mayankkt9 avatar Jan 08 '20 06:01 mayankkt9