BFS (Queue) , C++
Code\ncpp []\nclass Solution {\npublic:\n    int visit[100][100];\n    int dx[4] = {0,1,0,-1};\n    int dy[4] = {1,0,-1,0};\n    \n    struct Node {\n        in
# Code\n```cpp []\nclass Solution {\npublic:\n    int visit[100][100];\n    int dx[4] = {0,1,0,-1};\n    int dy[4] = {1,0,-1,0};\n    \n    struct Node {\n        int a;\n        int b;\n        int val;\n    };\n    \n    bool findSafeWalk(vector<vector<int>>& grid, int h) {\n        int n = grid.size() - 1;\n        int m = grid[0].size() - 1;\n        memset(visit,0,sizeof(visit));\n        \n        queue<Node> q;\n        q.push({0,0,h-grid[0][0]});\n        visit[0][0] = h - grid[0][0];\n        \n        while (!q.empty()) {\n            auto f = q.front();\n            q.pop();\n            \n            if (f.a == n && f.b == m && f.val >= 1) return true;\n            \n            for (int i = 0; i < 4; ++i) {\n                int x = f.a + dx[i];\n                int y = f.b + dy[i];\n                if (x >= 0 && x <= n && y >= 0 && y <= m ){\n                    int nh = f.val - grid[x][y];\n\n                    if (nh > 0) {\n                        if (visit[x][y] < nh) {\n                            visit[x][y] = nh;\n                            q.push({x, y, nh});\n                        }\n                    }\n                }\n            }\n        }\n        return false;\n    }\n};\n```
['C++']