EASY DIJIKSTRA ALGO  >>> 3d DP  ❤️
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```cpp []
#define VII vector<pair<int,int>>
#define II pair<int,int>
#define f first
#define s second
class Solution {
public:
    int dir[4][2] = { {0 , 1} , {0 , -1} , {1 , 0} , {-1 , 0}};
    bool findSafeWalk(vector<vector<int>>& grid, int health) {
        priority_queue <pair<int,II> , vector<pair<int,II>> , greater<pair<int,II>>> pq;

       
        pq.push({grid[0][0] , {0,0}});

        int m = grid.size() , n = grid[0].size();

        vector<vector<int>> dict (m , vector<int> (n , INT_MAX));
        dict[0][0] = grid[0][0];

        while (pq.size()) {
           pair<int,II>  pp = pq.top();
            pq.pop();
            int x = pp.s.f;
            int y = pp.s.s;

            for (int i = 0 ; i < 4 ; i += 1) {
                int u = x + dir[i][0];
                int v = y + dir[i][1];

                if (u >= 0 && v >= 0 && u < m && v < n){
                    if (dict[x][y] + grid[u][v] < dict[u][v]) {
                        dict[u][v] = dict[x][y] + grid[u][v];
                        if (dict[x][y] + grid[u][v] <= health)
                            pq.push ({dict[u][v] , {u,v}});
                    }
                }
            }
        }
        return (health > dict[m - 1][n - 1]);

    }
};
```
['C++']