01 BFS
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: O(n*m)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(n*m)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    int dx[4]={0,0,-1,1};\n    int dy[4]={1,-1,0,0};\n    int bfs(vector<vector<int>>& g){\n        int n = g.size();\n        int m = g[0].size();\n        deque<pair<int,int>>dq;\n        vector<vector<int>>dis(n,vector<int>(m,1e9));\n        dq.push_back({0,0});\n        dis[0][0]=g[0][0];\n        while(!dq.empty()){\n            auto cur = dq.front();\n            auto x=cur.first,y=cur.second;\n            dq.pop_front();\n            for(int k=0;k<4;k++){\n                int nx=x+dx[k];\n                int ny=y+dy[k];\n                if(nx>=0&&nx<n&&ny>=0&&ny<m){\n                    if(dis[nx][ny]>dis[x][y]+g[nx][ny]){\n                        dis[nx][ny]=dis[x][y]+g[nx][ny];\n                        if(!g[nx][ny]){\n                            dq.push_front({nx,ny});\n                        }\n                        else{\n                            dq.push_back({nx,ny});\n                        }\n                    }\n                }\n            }\n        }\n        return dis[n-1][m-1];\n    }\n    bool findSafeWalk(vector<vector<int>>& g, int h) {\n        ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);\n        return (h-bfs(g))>=1;\n    }\n};\n```
['Breadth-First Search', 'C++']