Djikstra Solution.
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:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    int minTimeToReach(vector<vector<int>>& moveTime) \n    {\n        int n = moveTime.size();\n        int m = moveTime[0].size();\n        vector<vector<long long>> dis(n,vector<long long>(m,1e12));\n        priority_queue<pair<pair<int,int>,pair<int,int>>,vector<pair<pair<int,int>,pair<int,int>>>,greater<pair<pair<int,int>,pair<int,int>>>> pq;\n        pq.push({{0,0},{0,0}});\n        dis[0][0] = 0;\n        vector<pair<int,int>> v = {{1,0},{-1,0},{0,1},{0,-1}};\n        while(!pq.empty())\n        {\n            auto node = pq.top();\n            pq.pop();\n            int t = node.first.first;\n            int mv = node.first.second;\n            int i = node.second.first;\n            int j = node.second.second;\n            // cout << t << " " << i << " " << j << endl;\n            for(auto it : v)\n            {\n                int r = i+it.first;\n                int c = j+it.second;\n                if(r >= n || c >= m || r < 0 || c < 0) continue;\n                if(dis[r][c] > (max(1LL*moveTime[r][c],dis[i][j]) + (mv == 0 ? 1 : 2)))\n                {\n                    dis[r][c] = (max(1LL*moveTime[r][c],dis[i][j]) + (mv == 0 ? 1 : 2));\n                    pq.push({{dis[r][c],mv^1},{r,c}});\n                }\n            }\n        }\n        return dis[n-1][m-1];\n    }\n};\n```
['C++']