Modified Dijkstra || Edge Cases || graph || C++
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```\nclass Solution {\npublic:\n    int minimumTime(vector<vector<int>>& a) {\n        \n    int m=a.size();\n    int n=a[0].size();\n    if(a[0][1]>1 && a[1][0]>1)\n     return -1;\n    //bool vis[m+1][n+1];\n   // memset(vis,false,sizeof(vis));\n    set<vector<int>> q;\n    q.insert({0,0,0});\n    vector<vector<int>> dp(m,vector<int>(n,INT_MAX));\n    dp[0][0]=0;\n    vector<int> dir{0,1,0,-1,0};\n\n    while(!q.empty())\n    {\n        vector<int> c=*(q.begin());\n        q.erase(q.begin());\n        int x=c[1],y=c[2];\n        int time=c[0];\n        if(x==(m-1) && y==(n-1))\n         return time;\n        for(int i=0;i<4;i++)\n        {\n            int nx=x+dir[i];\n            int ny=y+dir[i+1];\n            if(min(nx,ny)>=0 && nx<m && ny<n)\n            {\n                int d=a[nx][ny]-time;\n                if(time+1>=a[nx][ny] && time+1<dp[nx][ny])\n                {\n                    q.erase({dp[nx][ny],nx,ny});\n                    dp[nx][ny]=time+1;\n                    q.insert({dp[nx][ny],nx,ny});\n                }\n                else if(time+1<a[nx][ny])\n                {\n                    int d=a[nx][ny]-time;\n                    if(d%2)\n                    {\n                        if(a[nx][ny]<dp[nx][ny])\n                        {\n                             q.erase({dp[nx][ny],nx,ny});\n                             dp[nx][ny]=a[nx][ny];\n                             q.insert({dp[nx][ny],nx,ny});\n                        }\n                    }\n                    else\n                    {\n                        if(a[nx][ny]+1<dp[nx][ny])\n                        {\n                             q.erase({dp[nx][ny],nx,ny});\n                             dp[nx][ny]=a[nx][ny]+1;\n                             q.insert({dp[nx][ny],nx,ny});\n                        }\n                    }\n                }\n            }\n        }\n    }\n\n    return -1;\n     \n    }\n};\n```
['Graph', 'Ordered Set', 'C++']