Optimizing this maze-solver
Walking all zeros is indeed suboptimal. A good first optimization is to preferentially walk on the zeros that bring you closer to the end point.

To do this, at each step calculate the pythagorean distance between the x,y coords of the array entry you're considering walking to, and the x,y coords of the array entry containing -3. This will be the cost of walking to that square. Store all calculated costs so you don't have to recalculate them.

Then, continue to preferentially choose lowest-cost next squares until you reach the end or a dead end. In cases of dead ends, simply go back and choose the next lowest-cost square that has yet to be traversed. To do this, you will need to keep some notion of path hierarchy, i.e. which steps lead to which next potential steps. A custom node type will do this for you.

If you've made it this far, then congratulations! You have a rudimentary A* path-finding algorithm. For a helpful guide to implementing this algorithm I recommend this resource.

There are further enhancements to A* efficiency, such as the Jump Point Search algorithm, which is best for more open spaces.