Simnple dijkstra implementation
IntuitionDijkstraCode
# Intuition
Dijkstra


# Code
```cpp []
class Solution {
public:
    vector<pair<int, int>> directions = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
    int minTimeToReach(vector<vector<int>>& moveTime) {
        int m=moveTime.size();
        int n=moveTime[0].size();
        priority_queue<tuple<int, int, int, int>, vector<tuple<int, int, int, int>>, greater<tuple<int, int, int, int>>> pq;
        vector<vector<int>> time(m, vector<int>(n, INT_MAX));     
        pq.push({0, 0, 0, 0});
        time[0][0]=0;
        int value=INT_MAX;
        while(!pq.empty()){
            auto [t, i, j, flip] = pq.top();
            pq.pop();
            if(i==m-1 and j==n-1){
                value=min(value, t);
            }
            for(auto d : directions){
                int next_i=i+d.first;
                int next_j=j+d.second;
                if(next_i<0 or next_i>=m or next_j<0 or next_j>=n)continue;
                int next_time = max(t, moveTime[next_i][next_j]) + flip%2+1; 
                if (next_time  < time[next_i][next_j]) {
                    time[next_i][next_j] = next_time;
                    pq.push({next_time, next_i, next_j, flip%2+1});               
                }
            }
        }
        return value;
    }
};
```
['C++']