I was solving this problem of finding minimum path in a 2d array where there are some obstacles

i knoew this problem can be solved by BFS but i tried using backtracking can you please tell me what wrong with my code

You are given an M by N matrix consisting of booleans that represents a board. Each True boolean represents a wall. Each False boolean represents a tile you can walk on.

Given this matrix, a start coordinate, and an end coordinate, return the minimum number of steps required to reach the end coordinate from the start. If there is no possible path, then return null. You can move up, left, down, and right. You cannot move through walls. You cannot wrap around the edges of the board.

input ->
4
1 1 1 1 0 0 1 0 1 1 1 1 1 1 1 1

soln -

Hi
The problem is that backtracking logic does not apply to this solution as we need to find the minimum number of steps to reach the end state and not the number of ways to reach the end state as backtracking is branch and bound technique that eliminates infeasible solutions( solutions which are not possible) however here you are looking for an optimal solution(min steps out of all correct/feasible solutions) hence the issue
Thank you