Java : Two Queue Dijkstra Solution
I use two different queues for different cases.\nWhen I am processing node, with distance 1, I add it to the QueueTwo.\nWhen I am process node with distance 2, 
I use two different queues for different cases.\nWhen I am processing node, with distance 1, I add it to the QueueTwo.\nWhen I am process node with distance 2, I add it to the QueueOne.\n\n# Code\n```java []\nclass Solution {\n    public int minTimeToReach(int[][] moveTime) {\n        final int rowCount = moveTime.length;\n        final int columnCount = moveTime[0].length;\n\n        class ShortestPath {\n            final int[][] directionOffset = {{-1, 0}, {1, 0}, {0, 1}, {0, -1}};\n            final int[][] shortestTimeMatrix = new int[rowCount][columnCount];\n\n            int calculate(){\n                for(final int[] row : shortestTimeMatrix) Arrays.fill(row, Integer.MAX_VALUE);\n\n                final Queue<List<Integer>> timeQueueOne = new ArrayDeque<>();\n                timeQueueOne.offer(List.of(0, 0));\n                shortestTimeMatrix[0][0] = 0;\n\n                final Queue<List<Integer>> timeQueueTwo = new ArrayDeque<>();\n                int sequence = 0;\n\n                while(!timeQueueOne.isEmpty() || !timeQueueTwo.isEmpty()) {\n                    processQueue(timeQueueOne, timeQueueTwo, 1);\n                    processQueue(timeQueueTwo, timeQueueOne, 2);\n                }\n\n                return shortestTimeMatrix[rowCount - 1][columnCount - 1];\n            }\n\n            void processQueue(\n                final Queue<List<Integer>> sourceTimeQueue\n                , final Queue<List<Integer>> destinationTimeQueue\n                , final int addAmount\n            ){\n                while(!sourceTimeQueue.isEmpty()) {\n                    final List<Integer> cellCoordinate = sourceTimeQueue.poll();\n\n                    final int rowIndex = cellCoordinate.get(0);\n                    final int columnIndex = cellCoordinate.get(1);\n                    final int timeCostTillNow = shortestTimeMatrix[rowIndex][columnIndex];\n\n                    for(final int[] direction : directionOffset){\n                        final int rowOffset    = direction[0];\n                        final int columnOffset = direction[1];\n\n                        final int nextRowIndex    = rowIndex + rowOffset;\n                        if(nextRowIndex < 0 || nextRowIndex >= rowCount) continue;\n\n                        final int nextColumnIndex = columnIndex + columnOffset;\n                        if(nextColumnIndex < 0 || nextColumnIndex >= columnCount) continue;\n\n                        final int minimumTimeToMove = moveTime[nextRowIndex][nextColumnIndex];\n                        int updatedTimeTillNow = (timeCostTillNow > minimumTimeToMove) ? timeCostTillNow : minimumTimeToMove;\n\n                        final int shortestTimeCell = shortestTimeMatrix[nextRowIndex][nextColumnIndex];\n\n                        if(shortestTimeCell > (updatedTimeTillNow + addAmount)) {\n                            final int shortestTimeNow = updatedTimeTillNow + addAmount;\n                            shortestTimeMatrix[nextRowIndex][nextColumnIndex] = shortestTimeNow;\n                            destinationTimeQueue.offer(List.of(nextRowIndex, nextColumnIndex));\n                        }\n                    }\n                }\n            }\n        }\n\n        final ShortestPath shortestTime = new ShortestPath();\n        final int shortestTimeToLastRoom = shortestTime.calculate();\n\n        return shortestTimeToLastRoom;\n    }\n}\n```
['Shortest Path', 'Java']