Using Dijstra algorithm 100% faster 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- o(V+E)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n- O(V)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    typedef long long ll;\n    typedef pair<ll, pair<int, int>> iPair;\n    vector<int> x_cord = {1, 0, -1, 0};\n    vector<int> y_cord = {0, -1, 0, 1};\n\n    int minTimeToReach(vector<vector<int>>& moveTime) {\n       int m = moveTime.size(), n = moveTime[0].size();\n\n       int src =0;\n       vector<ll> dist(m*n, -1);\n\n       priority_queue<iPair, vector<iPair>, greater<iPair>> pq;\n\n       pq.push({0, {src, 1}});\n       dist[src] = 0;\n\n       while(!pq.empty()){\n          iPair node  = pq.top();\n          int x = node.second.first/n, y = node.second.first%n; \n          pq.pop();\n\n          for(int i=0;i<4;i++){ \n             int row = x + x_cord[i], col = y + y_cord[i];\n             int nbr = row*n + col;\n\n             if(row<0 || row> m-1) continue;\n             if(col<0 || col> n-1) continue;\n             \n             if(dist[nbr]==-1){\n                int next_move_time = node.second.second==1? 2:1;\n                ll nbr_dist = max(node.first, (long long)moveTime[row][col])+ node.second.second;\n                pq.push({nbr_dist, {nbr, next_move_time}});\n                dist[nbr] = nbr_dist;\n             }\n          }\n       }\n\n       return (int)dist[m*n-1];\n    }\n};\n```
['C++']