JAVA solution with simple calculation of moving time
Intuition\n Describe your first thoughts on how to solve this problem. \nwhen current cell is (i,j), the moving time is (i+j)%2+1.\n\n\n# Approach\n Describe yo
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nwhen current cell is (i,j), the moving time is (i+j)%2+1.\n\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```java []\nclass Solution {\n    public int minTimeToReach(int[][] t) {\n        final int[][] r = {{1,0},{-1,0},{0,1},{0,-1}};\n        int n=t.length;\n        int m=t[0].length;\n\n        int[][] d = new int[n][m];\n        for(int i=0; i<n; i++)Arrays.fill(d[i], 2_000_000_000);\n        d[0][0]=0;\n\n        PriorityQueue<node> q = new PriorityQueue<>();\n        q.add(new node(0,0,0));\n\n        int ni, nj, nv;\n        while(!q.isEmpty()){\n            node cur = q.poll();\n            if(cur.v>d[cur.i][cur.j])continue;\n\n            for(int[] rr:r){\n                ni=cur.i+rr[0]; nj=cur.j+rr[1];\n                if(ni<0||ni>=n||nj<0||nj>=m)continue;\n                nv=Math.max(cur.v, t[ni][nj])+(cur.i+cur.j)%2 +1;\n\n                if(nv<d[ni][nj]){\n                    d[ni][nj]=nv; q.add(new node(ni,nj,nv));\n                }\n            }\n        }\n        return d[n-1][m-1];\n    }\n    class node implements Comparable<node>{\n        int i, j, v;\n        node(int _i, int _j, int _v){\n            i=_i; j=_j; v=_v;\n        }\n        @Override\n        public int compareTo(node o){\n            return Integer.compare(this.v, o.v);\n        }\n    }\n}\n```
['Java']