Easy BFS ✅
Code\ncpp []\nclass Solution {\npublic:\n    int dr[4]={-1,1,0,0};\n    int dc[4]={0,0,-1,1};\n    int bfs(vector<vector<int>>& moveTime,int n,int m,vector<vect
# Code\n```cpp []\nclass Solution {\npublic:\n    int dr[4]={-1,1,0,0};\n    int dc[4]={0,0,-1,1};\n    int bfs(vector<vector<int>>& moveTime,int n,int m,vector<vector<int>>& time){\n        priority_queue<vector<int>,vector<vector<int>>,greater<vector<int>>>q;\n        q.push({0,0,0,0});\n        time[0][0]=0;\n        while(!q.empty()){\n            auto tp=q.top();\n            q.pop();\n            int timer=tp[0];\n            int move=tp[1];\n            int r=tp[2];\n            int c=tp[3];\n            for(int i=0;i<4;i++){\n                int nr=r+dr[i];\n                int nc=c+dc[i];\n                if(nr>=0 && nr<n && nc>=0 && nc<m){\n                    int maxTime=max(timer,moveTime[nr][nc])+move+1;\n                    if(maxTime<time[nr][nc]){\n                        if(nr==n-1 && nc==m-1) return maxTime;\n                        time[nr][nc]=maxTime;\n                        q.push({maxTime,1-move,nr,nc});\n                    }\n                }\n            }\n        }\n        return time[n-1][m-1];\n    }\n    int minTimeToReach(vector<vector<int>>& moveTime){\n        int n=moveTime.size();\n        int m=moveTime[0].size();\n        vector<vector<int>>time(n,vector<int>(m,INT_MAX));\n        return bfs(moveTime,n,m,time);\n    }\n};\n```
['Array', 'Breadth-First Search', 'Graph', 'Heap (Priority Queue)', 'Matrix', 'Shortest Path', 'C++']