Simple Dijkistra | beginner friendly
Intuitionthis problem was quite itnutive for me just thoughout of reacing next node if we can reach with current distance otherwise wait at that node as well he
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
this problem was quite itnutive for me just thoughout of reacing next node if we can reach with current distance otherwise wait at that node as well here take care of the step and alternate it between the two nodes as well

# 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 []
class Solution {
public:
    int minTimeToReach(vector<vector<int>>& moveTime) {
        vector<vector<int>> dist(moveTime.size(),vector<int> (moveTime[0].size(),INT_MAX));
        priority_queue<pair<int,pair<pair<int,int>,int>>,vector<pair<int,pair<pair<int,int>,int>>>,greater<pair<int,pair<pair<int,int>,int>>>> pq;
        pq.push(make_pair(0,make_pair(make_pair(0,0),2)));
        dist[0][0]=0;
        vector<int> dx={1,0,-1,0};
        vector<int> dy={0,1,0,-1};
        while(!pq.empty()){
            int currx=pq.top().second.first.first;
            int curry=pq.top().second.first.second;
            int step=pq.top().second.second;
            int dst=pq.top().first;
            pq.pop();
            if(step==1){
                step=2;
            }else{
                step=1;
            }
            for(int i=0;i<4;i++){
                int newx=currx+dx[i];
                int newy=curry+dy[i];
                if((newx>=0 && newx<moveTime.size()) && (newy>=0 && newy<moveTime[0].size())){
                    if(moveTime[newx][newy]<=dst){
                        if(dst+step<dist[newx][newy]){
                            dist[newx][newy]=dst+step;
                            pq.push(make_pair(dist[newx][newy],make_pair(make_pair(newx,newy),step)));
                        }
                    }else{
                        if(moveTime[newx][newy]+step<dist[newx][newy]){
                            dist[newx][newy]=moveTime[newx][newy]+step;                        
                            pq.push(make_pair(dist[newx][newy],make_pair(make_pair(newx,newy),step)));
                        }
                    }
                }
            }
        }
        return dist[moveTime.size()-1][moveTime[0].size()-1];
    }
};
```
['C++']