JS 🎊🎊🎉
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```javascript []\n/**\n * @param {number[][]} grid\n * @return {number}\n */\nvar minimumTime = function(grid) {\n    if(grid[0][1] > 1 && grid[1][0] > 1) return -1\n\n    const m = grid.length\n    const n = grid[0].length\n    const dirs = [[0,1],[1,0],[0,-1],[-1,0]]\n    const visited = Array.from({length: m}, ()=>Array(n).fill(false))\n    visited[0][0] = true\n\n    const pq = new MinPriorityQueue({priority: x => x[0]})\n    pq.enqueue([0,0,0])\n\n    while(!pq.isEmpty()){\n        let [t,i,j] = pq.dequeue().element\n\n        for(let [dx, dy] of dirs){\n            let x = i+dx\n            let y = j+dy\n            if(x < 0 || x >= m) continue\n            if(y < 0 || y >= n) continue\n            if(visited[x][y] === true) continue\n\n            let newTime = t+1\n            if(grid[x][y] > newTime){\n                newTime += Math.floor((grid[x][y] - t) / 2) * 2\n            }\n\n            if(x === m-1 && y === n-1){\n                return newTime\n            }\n            \n            visited[x][y] = true\n            pq.enqueue([newTime, x, y])\n        }\n    }\n\n\n    return -1\n};\n```
['JavaScript']