I\'m trying to solve 01 matrix problem https://leetcode.com/problems/01-matrix/ in LeetCode using DFS. I got a time limit exceeded with my naive DFS solution. I optimized it