3. Given the following maze and code snippet, what will be the output?
const maze = [
[1, 0, 0, 0],
[1, 1, 0, 1],
[0, 1, 0, 0],
[1, 1, 1, 1]
];
function isSafe(x: number, y: number): boolean {
return x >= 0 && y >= 0 && x < 4 && y < 4 && maze[x][y] === 1;
}
function solveMaze(x: number, y: number, path: string[]): boolean {
if (x === 3 && y === 3) {
path.push(`(${x},${y})`);
return true;
}
if (isSafe(x, y)) {
path.push(`(${x},${y})`);
if (solveMaze(x + 1, y, path)) return true;
if (solveMaze(x, y + 1, path)) return true;
path.pop();
}
return false;
}
const path: string[] = [];
if (solveMaze(0, 0, path)) {
console.log(path.join(' -> '));
} else {
console.log('No path found');
}