question_slug
stringlengths
3
77
title
stringlengths
1
183
slug
stringlengths
12
45
summary
stringlengths
1
160
author
stringlengths
2
30
certification
stringclasses
2 values
created_at
stringdate
2013-10-25 17:32:12
2025-04-12 09:38:24
updated_at
stringdate
2013-10-25 17:32:12
2025-04-12 09:38:24
hit_count
int64
0
10.6M
has_video
bool
2 classes
content
stringlengths
4
576k
upvotes
int64
0
11.5k
downvotes
int64
0
358
tags
stringlengths
2
193
comments
int64
0
2.56k
queens-that-can-attack-the-king
Java 1 ms Simple Implementation
java-1-ms-simple-implementation-by-sunny-6fwx
```\n\tpublic List> queensAttacktheKing(int[][] queens, int[] king) {\n List> coordinates= new ArrayList>();\n boolean[][] chessBoard= new boolean
sunnydhotre
NORMAL
2021-05-05T21:26:31.688076+00:00
2021-05-05T21:26:31.688106+00:00
99
false
```\n\tpublic List<List<Integer>> queensAttacktheKing(int[][] queens, int[] king) {\n List<List<Integer>> coordinates= new ArrayList<List<Integer>>();\n boolean[][] chessBoard= new boolean[8][8];\n for(int[] queenPos : queens){\n int x= queenPos[0], y= queenPos[1];\n chessBoar...
1
0
[]
0
queens-that-can-attack-the-king
python 3 solution o(n) time, 2 loops
python-3-solution-on-time-2-loops-by-shu-ytin
\nclass Solution:\n def queensAttacktheKing(self, queens: List[List[int]], king: List[int]) -> List[List[int]]:\n hashTable = {\n "lu": [],
shubhbhardwaj
NORMAL
2021-05-02T07:53:28.968524+00:00
2021-05-02T07:53:43.538144+00:00
139
false
```\nclass Solution:\n def queensAttacktheKing(self, queens: List[List[int]], king: List[int]) -> List[List[int]]:\n hashTable = {\n "lu": [],\n "uu": [],\n "ru": [],\n "rr": [],\n "rb": [],\n "bb": [],\n "lb": [],\n "ll":...
1
0
['Python', 'Python3']
0
queens-that-can-attack-the-king
86.74% faster c++ sol
8674-faster-c-sol-by-tjrandhawa26-mfn4
```\nclass Solution {\npublic:\n vector> queensAttacktheKing(vector>& queens, vector& king) \n {\n vector>ans;\n int i=king[0],j=king[1]-1;
Tjrandhawa26
NORMAL
2021-03-26T23:28:22.425808+00:00
2021-03-26T23:28:22.425844+00:00
49
false
```\nclass Solution {\npublic:\n vector<vector<int>> queensAttacktheKing(vector<vector<int>>& queens, vector<int>& king) \n {\n vector<vector<int>>ans;\n int i=king[0],j=king[1]-1;\n /*for left row */\n while(j>=0)\n {\n if(count(queens.begin(),queens.end(),vector<in...
1
0
[]
0
queens-that-can-attack-the-king
easy c++ code faster than 100 percent
easy-c-code-faster-than-100-percent-by-s-dqyq
class Solution {\npublic:\n vector> queensAttacktheKing(vector>& queens, vector& king) {\n int chess[8][8]={0};\n int i,j;\n int n=queen
shubhamsinhanitt
NORMAL
2021-01-09T10:20:38.866475+00:00
2021-01-09T10:20:38.866507+00:00
61
false
class Solution {\npublic:\n vector<vector<int>> queensAttacktheKing(vector<vector<int>>& queens, vector<int>& king) {\n int chess[8][8]={0};\n int i,j;\n int n=queens.size();\n int x=king[0];\n int y=king[1];\n vector<vector<int>>res;\n chess[x][y]=1;\n for(i=0...
1
0
[]
0
queens-that-can-attack-the-king
Java Easy Approach [beats 100% | Recursive ]. Code is talking for itself
java-easy-approach-beats-100-recursive-c-71f5
class Solution {\n public List<List<Integer>> queensAttacktheKing(int[][] queens, int[] king) {\n int[][] board = new int[8][8];\n List<List<In
akezhr
NORMAL
2021-01-02T09:01:20.276990+00:00
2021-01-02T09:01:20.277038+00:00
77
false
```class Solution {\n public List<List<Integer>> queensAttacktheKing(int[][] queens, int[] king) {\n int[][] board = new int[8][8];\n List<List<Integer>> ans = new ArrayList();\n \n for (int[] pos : queens) {\n board[pos[0]][pos[1]] = 1;\n }\n \n // There are 8...
1
0
[]
0
queens-that-can-attack-the-king
C++ unordered_set
c-unordered_set-by-michelusa-tgwo
\nstore queens coordinates in an unordered_set and find first match (if any) from king, in 8 directions.\n```\nclass Solution {\n constexpr static int SIZE
michelusa
NORMAL
2020-11-28T02:16:47.121054+00:00
2020-11-28T02:20:12.391588+00:00
141
false
\nstore queens coordinates in an unordered_set and find first match (if any) from king, in 8 directions.\n```\nclass Solution {\n constexpr static int SIZE = 8;\n \n struct hasher {\n size_t operator() (const pair<int,int>& coords)const {\n return coords.first*8 + coords.second;\n }\n...
1
0
['C']
0
queens-that-can-attack-the-king
python3
python3-by-bakerston-ctin
\ndef queensAttacktheKing(queens,king):\n\t\tfrom collections import defaultdict\n\t\ta=defaultdict(lambda: 8)\n\t\tfor x in queens:\n\t\t\tif x[0]==king[0] and
Bakerston
NORMAL
2020-11-19T03:00:57.607515+00:00
2020-11-19T03:00:57.607544+00:00
96
false
```\ndef queensAttacktheKing(queens,king):\n\t\tfrom collections import defaultdict\n\t\ta=defaultdict(lambda: 8)\n\t\tfor x in queens:\n\t\t\tif x[0]==king[0] and x[1]>king[1]:\n\t\t\t\ta["N"]=min(a["N"],x[1]-king[1])\n\t\telif x[0]==king[0] and x[1]<king[1]:\n\t\t\ta["S"]=min(a["S"],king[1]-x[1])\n\t\telif x[1]==king...
1
0
[]
0
find-minimum-time-to-reach-last-room-ii
Easy & Clear Solution (Java, c++, Python3)
easy-clear-solution-java-c-python3-by-mo-xb2n
\n\n### Problem Explanation\n\nIn this problem, you are navigating through a dungeon represented by a grid of rooms. Each room has a specified minimum time (mov
moazmar
NORMAL
2024-11-03T04:15:31.630359+00:00
2024-11-03T04:49:04.180256+00:00
1,597
false
\n\n### Problem Explanation\n\nIn this problem, you are navigating through a dungeon represented by a grid of rooms. Each room has a specified minimum time (`moveTime[i][j]`) indicating when you can start moving into that room. You begin at the top-left room `(0, 0)` at time `t = 0` and aim to reach the bottom-right ro...
18
3
['C++', 'Java', 'Python3']
3
find-minimum-time-to-reach-last-room-ii
Python3 || 13 lines, heap and toggle ||
python3-13-lines-heap-and-toggle-by-spau-98ho
Pretty much the same as the preceding problem, with the added feature that the step toggles between 1 and 2, which we achieve by replacing step with 3 - step.\
Spaulding_
NORMAL
2024-11-03T22:16:23.360426+00:00
2024-11-12T17:09:16.189217+00:00
437
false
Pretty much the same as the preceding problem, with the added feature that the step toggles between 1 and 2, which we achieve by replacing `step` with `3 - step`.\n\n```python3 []\nclass Solution:\n def minTimeToReach(self, moveTime: List[List[int]]) -> int:\n \n onGrid = lambda x, y: 0 <= x < n and 0...
16
0
['C++', 'Java', 'Python3']
2
find-minimum-time-to-reach-last-room-ii
Modified Dijkstra's Algorithm
modified-dijkstras-algorithm-by-donpaul2-jvud
Use a priority queue containing a tuple of size 4.1st element in the tuple denotes time taken to reach that cell (negetive to maintain min heap) 2nd and 3rd are
donpaul271
NORMAL
2024-11-03T04:35:19.539972+00:00
2025-03-03T01:50:47.700543+00:00
2,464
false
Use a priority queue containing a tuple of size 4. 1st element in the tuple denotes time taken to reach that cell (negetive to maintain min heap) 2nd and 3rd are the x and y axis. 4th element denotes the decision variable dec. when dec is 0 it implies it takes 1 second to move when dec is 1 it implies it takes 2 se...
15
0
['C++']
2
find-minimum-time-to-reach-last-room-ii
[Java/C++/Python] Priority Queue
javacpython-priority-queue-by-lee215-f188
Intuition\nUse priority queue.\n\n\n# Explanation\nThe key is [t, c, i, j],\nwhere it takes t seconds to arrive (i, j),\nthe next move will cost c seconds.\n\nU
lee215
NORMAL
2024-11-03T04:13:35.207550+00:00
2024-11-04T03:15:10.499580+00:00
952
false
# **Intuition**\nUse priority queue.\n<br>\n\n# **Explanation**\nThe key is `[t, c, i, j]`,\nwhere it takes `t` seconds to arrive `(i, j)`,\nthe next move will cost `c` seconds.\n\nUse `3 - d` to determine the next cost of move.\n<br>\n\n# **Complexity**\nTime `O(mnlogmn)`\nSpace `O(mn)`\n<br>\n\n```Java [Java]\n pu...
9
0
[]
3
find-minimum-time-to-reach-last-room-ii
Easiest Solution 🔥✅ | Modified Dijkstra's
easiest-solution-modified-dijkstras-by-1-53qz
Approach\nExactly the same as:\nhttps://leetcode.com/problems/find-minimum-time-to-reach-last-room-i/solutions/6000113/easiest-solution-heap-bfs/\nOnly differen
1AFN19tfV2
NORMAL
2024-11-03T04:01:18.748178+00:00
2024-11-04T16:58:04.200094+00:00
802
false
# Approach\nExactly the same as:\nhttps://leetcode.com/problems/find-minimum-time-to-reach-last-room-i/solutions/6000113/easiest-solution-heap-bfs/\nOnly difference is we add a new value `check` into the heap which we will use to check if we need to add 1 or 2 to the current time. This change is made when we push again...
6
0
['Heap (Priority Queue)', 'Shortest Path', 'C++', 'Java', 'Python3']
0
find-minimum-time-to-reach-last-room-ii
Detailed Dry-Run Approach
detailed-dry-run-approach-by-mainframeku-rxdd
Intuition\n Describe your first thoughts on how to solve this problem. \nThe problem requires us to navigate through a grid of rooms, each with a designated tim
MainFrameKuznetSov
NORMAL
2024-11-03T07:08:19.331345+00:00
2024-11-03T07:08:19.331368+00:00
80
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe problem requires us to navigate through a grid of rooms, each with a designated time that must pass before we can move into it.To solve this, the use of a graph traversal algorithm is necessary since the solution involves finding the ...
5
0
['Graph', 'Heap (Priority Queue)', 'Shortest Path', 'C++']
0
find-minimum-time-to-reach-last-room-ii
[Python3/C++/Java] Dijkstra - Detailed Solution
python3cjava-dijkstra-detailed-solution-nb4rf
Intuition\n Describe your first thoughts on how to solve this problem. \n- Shortest Path with a lot of constraints and conditions\n- All parameters are posivite
dolong2110
NORMAL
2024-11-16T12:46:56.467631+00:00
2024-11-16T12:51:56.081314+00:00
128
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n- Shortest Path with a lot of constraints and conditions\n- All parameters are posivite\n- It is the signal of Dijkstra or BFS\n- Each going path has its own weight. Thus Dijkstra\n\n# Approach\n<!-- Describe your approach to solving the ...
4
0
['Array', 'Graph', 'Heap (Priority Queue)', 'Matrix', 'Shortest Path', 'C++', 'Java', 'Python3']
0
find-minimum-time-to-reach-last-room-ii
[C++] Djikstra's + Easy Hack for deciding between 1 or 2 (Even vs Odd Diagonal)
c-djikstras-easy-hack-for-deciding-betwe-u2ga
Intuition\n Describe your first thoughts on how to solve this problem. \nSame approach as 3341. but instead we have to account for either adding 1 or 2 dependin
frvnk
NORMAL
2024-11-03T04:22:20.727121+00:00
2024-11-03T18:00:32.888421+00:00
559
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nSame approach as [3341.](https://leetcode.com/problems/find-minimum-time-to-reach-last-room-i/description/) but instead we have to account for either adding 1 or 2 depending on the room. Note that traveling into rooms on odd diagonals wil...
3
0
['C++']
2
find-minimum-time-to-reach-last-room-ii
Constest - 3/11/2024 || Q-3 || BFS || Heap
constest-3112024-q-3-bfs-heap-by-sajalti-qekl
Approach\n\n1. Modeling the Problem:\n - Each cell in the grid represents a point that can be traversed, with a cost associated with moving into that cell def
sajaltiwari007
NORMAL
2024-11-03T04:10:09.116772+00:00
2024-11-03T04:10:09.116794+00:00
97
false
### Approach\n\n1. **Modeling the Problem**:\n - Each cell in the grid represents a point that can be traversed, with a cost associated with moving into that cell defined by the `moveTime` array.\n - The objective is to minimize the time taken to reach the cell at `(n-1, m-1)` starting from `(0, 0)`.\n\n2. **Data S...
3
0
['Breadth-First Search', 'Heap (Priority Queue)', 'Java']
0
find-minimum-time-to-reach-last-room-ii
Simple C++ Solution || (Using Dijkstra's Algo) ✅✅
simple-c-solution-using-dijkstras-algo-b-3ycn
Code\ncpp []\nclass Solution {\npublic:\n int di[4]={1,-1,0,0};\n int dj[4]={0,0,1,-1};\n int minTimeToReach(vector<vector<int>>& moveTime) {\n
Abhi242
NORMAL
2024-11-04T14:48:51.653287+00:00
2024-11-04T14:48:51.653325+00:00
115
false
# Code\n```cpp []\nclass Solution {\npublic:\n int di[4]={1,-1,0,0};\n int dj[4]={0,0,1,-1};\n int minTimeToReach(vector<vector<int>>& moveTime) {\n int n=moveTime.size();\n int m=moveTime[0].size();\n vector<vector<int>> dist(n,vector<int>(m,INT_MAX));\n priority_queue<pair<int,pai...
2
0
['Graph', 'C++']
0
find-minimum-time-to-reach-last-room-ii
EASY C++ Solution Beats 100% of the user || find-minimum-time-to-reach-last-room-ii
easy-c-solution-beats-100-of-the-user-fi-f2ra
\n\n# Code\ncpp []\nclass Solution {\npublic:\n int minTimeToReach(vector<vector<int>>& mv) {\n int m = mv.size();\n int n = mv[0].size(); \n
ZugsWang
NORMAL
2024-11-03T08:37:49.213320+00:00
2024-11-03T08:37:49.213353+00:00
132
false
\n\n# Code\n```cpp []\nclass Solution {\npublic:\n int minTimeToReach(vector<vector<int>>& mv) {\n int m = mv.size();\n int n = mv[0].size(); \n priority_queue<pair<pair<int,int>,pair<int,int>>,vector<pair<pair<int,int>,pair<int,int>>>,greater<pair<pair<int,int>,pair<int,int>>>>pq;//{{t,len},{x,...
2
0
['Breadth-First Search', 'Graph', 'Heap (Priority Queue)', 'C++']
0
find-minimum-time-to-reach-last-room-ii
Python Solution
python-solution-by-pranav743-2c20
Approach\nShortest Path Algoritm - Dijkstra\'s\n\n# Complexity\n- Time complexity: O( (nm) * log(nm) )\n- Space complexity: O(2nm)\n\n# Code\npython3 []\nclass
pranav743
NORMAL
2024-11-03T04:03:21.620528+00:00
2024-11-03T04:03:21.620552+00:00
156
false
# Approach\nShortest Path Algoritm - Dijkstra\'s\n\n# Complexity\n- Time complexity: $$O( (n*m) * log(n*m) )$$\n- Space complexity: $$O(2*n*m)$$\n\n# Code\n```python3 []\nclass Solution:\n def minTimeToReach(self, matrix: List[List[int]]) -> int:\n\n num_rows = len(matrix)\n num_cols = len(matrix[0])\n...
2
0
['Heap (Priority Queue)', 'Shortest Path', 'Python3']
0
find-minimum-time-to-reach-last-room-ii
Java Clean Solution - 3/11/2024
java-clean-solution-3112024-by-shree_gov-sbid
Complexity\n- Time complexity:O(nm)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity:O(nm*2)\n Add your space complexity here, e.g. O(n) \n\n#
Shree_Govind_Jee
NORMAL
2024-11-03T04:03:13.664119+00:00
2024-11-03T04:03:13.664145+00:00
141
false
# Complexity\n- Time complexity:$$O(n*m)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:$$O(n*m*2)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```java []\nclass Pair implements Comparable<Pair> {\n int x;\n int y;\n int parity;\n int time;\n\n publ...
2
1
['Array', 'Math', 'Dynamic Programming', 'Queue', 'Heap (Priority Queue)', 'Java']
1
find-minimum-time-to-reach-last-room-ii
✅ Simple Java Solution + Heap
simple-java-solution-heap-by-harsh__005-47e7
CODE\nJava []\nint[][] dirs = new int[][]{{-1,0}, {1,0}, {0,-1}, {0,1}};\npublic int minTimeToReach(int[][] moveTime) {\n int n=moveTime.length, m = moveTime
Harsh__005
NORMAL
2024-11-03T04:02:14.296718+00:00
2024-11-03T04:10:02.199710+00:00
261
false
## **CODE**\n```Java []\nint[][] dirs = new int[][]{{-1,0}, {1,0}, {0,-1}, {0,1}};\npublic int minTimeToReach(int[][] moveTime) {\n int n=moveTime.length, m = moveTime[0].length;\n PriorityQueue<int[]> pq = new PriorityQueue<>((a,b)->a[2]-b[2]);\n\t\n\t// 0 -> R, 1 -> C, 2 -> Cost to Reach that Room, 3 -> First o...
2
0
['Java']
1
find-minimum-time-to-reach-last-room-ii
c++ solution
c-solution-by-dilipsuthar60-l5nj
\nclass Solution {\npublic:\n int minTimeToReach(vector<vector<int>>& mat) {\n int n=mat.size();\n int m=mat[0].size();\n priority_queue
dilipsuthar17
NORMAL
2024-11-03T04:01:40.282722+00:00
2024-11-03T04:01:40.282749+00:00
186
false
```\nclass Solution {\npublic:\n int minTimeToReach(vector<vector<int>>& mat) {\n int n=mat.size();\n int m=mat[0].size();\n priority_queue<tuple<long long,long long,int>,vector<tuple<long long,long long,int>>,greater<tuple<long long,long long,int>>>pq;\n vector<pair<int,int>>d={{-1,0},{1...
2
1
['C', 'C++']
0
find-minimum-time-to-reach-last-room-ii
Modified Dijkstra - Intuition based
modified-dijkstra-intuition-based-by-shi-dutx
IntuitionApproachComplexity Time complexity: Space complexity: Code
shivanshudobhal
NORMAL
2025-03-20T06:13:01.704708+00:00
2025-03-20T06:13:01.704708+00:00
46
false
# Intuition <!-- Describe your first thoughts on how to solve this problem. --> # Approach <!-- Describe your approach to solving the problem. --> # Complexity - Time complexity: <!-- Add your time complexity here, e.g. $$O(n)$$ --> - Space complexity: <!-- Add your space complexity here, e.g. $$O(n)$$ --> # Code `...
1
0
['C++']
0
find-minimum-time-to-reach-last-room-ii
[Java] Easy solution with min Heap
java-easy-solution-with-min-heap-by-ytch-ilzk
java\nclass Solution {\n public int minTimeToReach(final int[][] moveTime) {\n final int n = moveTime.length, m = moveTime[0].length;\n final Q
YTchouar
NORMAL
2024-11-07T23:08:19.281096+00:00
2024-11-07T23:08:19.281133+00:00
38
false
```java\nclass Solution {\n public int minTimeToReach(final int[][] moveTime) {\n final int n = moveTime.length, m = moveTime[0].length;\n final Queue<int[]> queue = new PriorityQueue<>((a, b) -> a[2] - b[2]);\n final int[][] dp = new int[n][m];\n final int[][] directions = new int[][] { ...
1
0
['Java']
0
find-minimum-time-to-reach-last-room-ii
Why don't AC solutions consider cost state in distance calculation ?
why-dont-ac-solutions-consider-cost-stat-yi54
\n Describe your first thoughts on how to solve this problem. \nAll of them use djisktra to normalise weight with the condition\nAssuming dist[i][j] -> Minimum
y_g
NORMAL
2024-11-07T15:21:28.488797+00:00
2024-11-07T15:21:28.488835+00:00
7
false
\n<!-- Describe your first thoughts on how to solve this problem. -->\nAll of them use djisktra to normalise weight with the condition\nAssuming dist[i][j] -> Minimum time to reach (i,j)\nAnd we insert into PQ (Min Heap) as (minArrivalTime, nextStepCost, nextRow, nextCol)\nAlso assume matrix[n-1][m-1] = 0 (To simply sa...
1
0
['C++']
0
find-minimum-time-to-reach-last-room-ii
[C++] Dijkstra once again
c-dijkstra-once-again-by-bora_marian-n4he
Same approach Like solution: https://leetcode.com/problems/find-minimum-time-to-reach-last-room-i/solutions/6011112/c-dijkstra-algorithm-implemented-using-a-set
bora_marian
NORMAL
2024-11-05T19:48:00.674234+00:00
2024-11-05T19:48:00.674267+00:00
117
false
Same approach Like solution: https://leetcode.com/problems/find-minimum-time-to-reach-last-room-i/solutions/6011112/c-dijkstra-algorithm-implemented-using-a-set/\nA Dijkstra implementation processing the cells with the smallest time first.\nThe difference between the 2 solutions is that we keep track also of the distan...
1
0
['C++']
0
find-minimum-time-to-reach-last-room-ii
BFS
bfs-by-pragati3003-ukwa
\n\n# Code\ncpp []\nclass Solution {\npublic:\n int minTimeToReach(vector<vector<int>>& moveTime) {\n int n = moveTime.size();\n int m = moveTi
Pragati3003
NORMAL
2024-11-03T14:48:41.779992+00:00
2024-11-03T14:48:41.780019+00:00
18
false
\n\n# Code\n```cpp []\nclass Solution {\npublic:\n int minTimeToReach(vector<vector<int>>& moveTime) {\n int n = moveTime.size();\n int m = moveTime[0].size();\n priority_queue<tuple<int, int, int, bool>,\n vector<tuple<int, int, int, bool>>, greater<>>\n pq;\n\n...
1
0
['Heap (Priority Queue)', 'C++']
0
find-minimum-time-to-reach-last-room-ii
Easy Dijkstra's solution using min heap
easy-dijkstras-solution-using-min-heap-b-u0f9
Intution\nUsing Dijkstras \n1. For finding the shortest path from starting point to ending point , the first approach comes in mind is dijkstras shortest path
be_fighter
NORMAL
2024-11-03T08:03:37.914808+00:00
2024-11-03T08:03:37.914852+00:00
100
false
# Intution\nUsing Dijkstras \n1. For finding the shortest path from starting point to ending point , the first approach comes in mind is dijkstras shortest path algorithm\n2. There is slight modification in algorithm according the question \n3. In even move it take +2 seconds and on odd +1 seconds\n4. We have take min...
1
0
['Depth-First Search', 'Heap (Priority Queue)', 'Shortest Path', 'C++', 'Java', 'Python3', 'JavaScript']
1
find-minimum-time-to-reach-last-room-ii
Dijkstra with one extra state | c++
dijkstra-with-one-extra-state-c-by-karna-buan
I hope you are clear with 1st part of the problem where this move_made part was not there and rest was the same problem\nlink to my editorial for that problem -
karna001
NORMAL
2024-11-03T04:41:43.323528+00:00
2024-11-03T04:41:43.323553+00:00
94
false
I hope you are clear with 1st part of the problem where this move_made part was not there and rest was the same problem\nlink to my editorial for that problem - https://leetcode.com/problems/find-minimum-time-to-reach-last-room-i/discuss/6000326/Dijkstra-or-Graph-or-c%2B%2B\n\nso here the extra catch is :\n**Moving bet...
1
0
['C']
0
find-minimum-time-to-reach-last-room-ii
Dijkstra wait till available
dijkstra-wait-till-available-by-theabbie-fgk3
\nimport heapq\n\nclass Solution:\n def minTimeToReach(self, moveTime: List[List[int]]) -> int:\n m = len(moveTime)\n n = len(moveTime[0])\n
theabbie
NORMAL
2024-11-03T04:01:30.899515+00:00
2024-11-03T04:01:30.899554+00:00
86
false
```\nimport heapq\n\nclass Solution:\n def minTimeToReach(self, moveTime: List[List[int]]) -> int:\n m = len(moveTime)\n n = len(moveTime[0])\n dist = [[float(\'inf\')] * n for _ in range(m)]\n dist[0][0] = 0\n heap = [(0, 0, 0, True)]\n while heap:\n d, i, j, eve...
1
0
['Python']
0
find-minimum-time-to-reach-last-room-ii
[Tag: Easy] TEXTBOOK TOGGLY-DIJKSTRA
tag-easy-textbook-toggly-dijkstra-by-tbn-kswl
This is toggly-dijkstra, and a really good question. For each node i, in the dist array maintain two values -> dist[i][0] = min dist from src to node i such th
tbne1905
NORMAL
2025-04-09T19:01:24.323422+00:00
2025-04-09T19:01:24.323422+00:00
1
false
This is toggly-dijkstra, and a really good question. - For each node i, in the dist array maintain two values -> dist[i][0] = min dist from src to node i such that landed on i in the first move from its previous node -> dist[i][1] = min dist from src to node i such that landed on i in the second move from its previous...
0
0
['C#']
0
find-minimum-time-to-reach-last-room-ii
Very Easy To Understand Solution - Just Do Dry Run
very-easy-to-understand-solution-just-do-uncw
Complexity Time complexity: O(n×m×log(n×m)) Space complexity:O(n×m) Code
sumamakhan
NORMAL
2025-03-22T04:31:05.437832+00:00
2025-03-22T04:31:05.437832+00:00
3
false
# Complexity - Time complexity: $$O(n×m×log(n×m))$$ <!-- Add your time complexity here, e.g. $$O(n)$$ --> - Space complexity:$$O(n×m)$$ <!-- Add your space complexity here, e.g. $$O(n)$$ --> # Code ```java [] class Solution { class Node { int x; int y; int time; int move; ...
0
0
['Java']
0
find-minimum-time-to-reach-last-room-ii
Very Easy To Understand Solution - Just Do Dry Run
very-easy-to-understand-solution-just-do-sz3b
Code
sumamakhan
NORMAL
2025-03-22T04:26:58.388504+00:00
2025-03-22T04:26:58.388504+00:00
2
false
# Code ```java [] class Solution { class Node { int x; int y; int time; int move; public Node(int x, int y, int time, int move) { this.x = x; this.y = y; this.time = time; this.move = move; } } public int min...
0
0
['Java']
0
find-minimum-time-to-reach-last-room-ii
C# Solution 64ms
c-solution-64ms-by-slowpuppy-wj7w
IntuitionI will modify this post later.ApproachComplexity Time complexity: Space complexity: Code
Slowpuppy
NORMAL
2025-03-20T23:41:58.019830+00:00
2025-03-20T23:41:58.019830+00:00
2
false
# Intuition <!-- Describe your first thoughts on how to solve this problem. --> I will modify this post later. # Approach <!-- Describe your approach to solving the problem. --> # Complexity - Time complexity: <!-- Add your time complexity here, e.g. $$O(n)$$ --> - Space complexity: <!-- Add your space complexity her...
0
0
['C#']
0
find-minimum-time-to-reach-last-room-ii
easy
easy-by-aj__style20233032-s01c
IntuitionApproachComplexity Time complexity: Space complexity: Code
Aj__style20233032
NORMAL
2025-03-16T19:47:29.150239+00:00
2025-03-16T19:47:29.150239+00:00
2
false
# Intuition <!-- Describe your first thoughts on how to solve this problem. --> # Approach <!-- Describe your approach to solving the problem. --> # Complexity - Time complexity: <!-- Add your time complexity here, e.g. $$O(n)$$ --> - Space complexity: <!-- Add your space complexity here, e.g. $$O(n)$$ --> # Code `...
0
0
['C++']
0
find-minimum-time-to-reach-last-room-ii
Looks like a simple `bfs` would work? Hmm..let's optimize it.
looks-like-a-simple-bfs-would-work-hmmle-m86z
IntuitionLooks like a simple bfs would work? Hmm..let's optimize it.ApproachIf you are at a cell say x with Tx time, you can move to an adjacent cell y with Ty
pratyushtiwarimj
NORMAL
2025-03-05T15:37:52.479879+00:00
2025-03-05T15:37:52.479879+00:00
1
false
# Intuition <!-- Describe your first thoughts on how to solve this problem. --> Looks like a simple `bfs` would work? Hmm..let's optimize it. # Approach <!-- Describe your approach to solving the problem. --> If you are at a cell say `x` with `Tx` time, you can move to an adjacent cell `y` with `Ty` time with the fol...
0
0
['C++']
0
find-minimum-time-to-reach-last-room-ii
[C++] Priority Queue (Shortest Path)
c-priority-queue-shortest-path-by-amanme-4vib
Code
amanmehara
NORMAL
2025-03-03T04:59:17.656017+00:00
2025-03-03T04:59:17.656017+00:00
4
false
# Code ```cpp [] class Solution { public: int minTimeToReach(vector<vector<int>>& move_time) { int n = move_time.size(); int m = move_time[0].size(); vector<vector<int>> min_time(n, vector<int>(m, INT_MAX)); min_time[0][0] = 0; vector<pair<int, int>> deltas({{-1, 0}, {0, -1},...
0
0
['Array', 'Graph', 'Heap (Priority Queue)', 'Matrix', 'Shortest Path', 'C++']
0
find-minimum-time-to-reach-last-room-ii
CPP||ModifiedDijikastra
cppmodifieddijikastra-by-_shubhambhardwa-27q5
IntuitionApproachComplexity Time complexity: Space complexity: Code
_ShubhamBhardwaj_
NORMAL
2025-02-27T15:59:00.847411+00:00
2025-02-27T15:59:00.847411+00:00
1
false
# Intuition <!-- Describe your first thoughts on how to solve this problem. --> # Approach <!-- Describe your approach to solving the problem. --> # Complexity - Time complexity: <!-- Add your time complexity here, e.g. $$O(n)$$ --> - Space complexity: <!-- Add your space complexity here, e.g. $$O(n)$$ --> # Code `...
0
0
['C++']
0
find-minimum-time-to-reach-last-room-ii
c++ solution
c-solution-by-amit_207-3qjl
IntuitionApproachComplexity Time complexity: Space complexity: Code
Amit_207
NORMAL
2025-02-22T12:36:40.846362+00:00
2025-02-22T12:36:40.846362+00:00
2
false
# Intuition <!-- Describe your first thoughts on how to solve this problem. --> # Approach <!-- Describe your approach to solving the problem. --> # Complexity - Time complexity: <!-- Add your time complexity here, e.g. $$O(n)$$ --> - Space complexity: <!-- Add your space complexity here, e.g. $$O(n)$$ --> # Code `...
0
0
['C++']
0
find-minimum-time-to-reach-last-room-ii
Python3 solution | Dijkstra
python3-solution-dijkstra-by-florinnc1-7qka
IntuitionUsing dijkstra, it's almost identical to3342. Find Minimum Time to Reach Last Room IIand pretty similar to778. Swim in Rising Water.ApproachUse dijkstr
FlorinnC1
NORMAL
2025-02-18T20:00:14.968000+00:00
2025-02-18T20:00:14.968000+00:00
4
false
# Intuition Using dijkstra, it's almost identical to $$ $$***3342. Find Minimum Time to Reach Last Room II***$$ $$ and pretty similar to $$ $$***778. Swim in Rising Water***$$ $$. # Approach Use dijkstra to maintain the level of time to reach each room. The time to the next adjacent cell will be when parity is 0: $$di...
0
0
['Python3']
0
find-minimum-time-to-reach-last-room-ii
Shortest Path | Simple Dijkstra's algorithm
shortest-path-simple-dijkstras-algorithm-85l4
Complexity Time complexity: O(N x M x log(N x M)) Space complexity: O(N x M) Code
rohanmathur91
NORMAL
2025-02-16T14:12:06.352623+00:00
2025-02-16T14:12:06.352623+00:00
3
false
# Complexity - Time complexity: O(N x M x log(N x M)) <!-- Add your time complexity here, e.g. $$O(n)$$ --> - Space complexity: O(N x M) <!-- Add your space complexity here, e.g. $$O(n)$$ --> # Code ```python3 [] class Solution: def minTimeToReach(self, moveTime: List[List[int]]) -> int: """ - Di...
0
0
['Graph', 'Heap (Priority Queue)', 'Shortest Path', 'Python3']
0
find-minimum-time-to-reach-last-room-ii
C++ priority_queue minimal time
c-priority_queue-minimal-time-by-the_ghu-rllz
null
the_ghuly
NORMAL
2025-02-12T10:47:07.239380+00:00
2025-02-12T10:47:07.239380+00:00
3
false
```cpp [] class Solution { public: int minTimeToReach(vector<vector<int>>& moveTime) { int m = moveTime.size(); int n = moveTime[0].size(); int dir[5]{0,1,0,-1,0}; vector<vector<bool>> visited(m, vector<bool>(n)); priority_queue<array<int,4>> pq; pq.push({0,0,0,1}); ...
0
0
['C++']
0
find-minimum-time-to-reach-last-room-ii
Simnple dijkstra implementation
simnple-dijkstra-implementation-by-saiku-nnzz
IntuitionDijkstraCode
saikumarkundlapelli
NORMAL
2025-01-28T16:28:03.860098+00:00
2025-01-28T16:28:03.860098+00:00
3
false
# Intuition Dijkstra # Code ```cpp [] class Solution { public: vector<pair<int, int>> directions = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}}; int minTimeToReach(vector<vector<int>>& moveTime) { int m=moveTime.size(); int n=moveTime[0].size(); priority_queue<tuple<int, int, int, int>, vector<t...
0
0
['C++']
0
find-minimum-time-to-reach-last-room-ii
Dijkstra's Algorithm/easy.
dijkstras-algorithmeasy-by-rishiinsane-e1c1
IntuitionApproachTo understand the problem better we can consider moveTime as unlockTime.We move to the cell that unlocks the earliest only then we can reach th
RishiINSANE
NORMAL
2025-01-23T13:05:50.825243+00:00
2025-01-23T13:05:50.825243+00:00
5
false
# Intuition <!-- Describe your first thoughts on how to solve this problem. --> # Approach To understand the problem better we can consider moveTime as unlockTime.We move to the cell that unlocks the earliest only then we can reach the cell `n-1,m-1` in the least possible time. Thus we need access to the cell that unl...
0
0
['C++']
0
find-minimum-time-to-reach-last-room-ii
Minimum Time to Traverse Grid with Alternating Costs Using Dijkstra's Algorithm using visited array
minimum-time-to-traverse-grid-with-alter-euk5
IntuitionThe problem requires finding the minimum time to traverse a grid where each cell represents a waiting time, and moves alternate between a cost of 1 and
prashantiiitnag
NORMAL
2025-01-18T11:21:56.789517+00:00
2025-01-18T11:21:56.789517+00:00
7
false
# Intuition <!-- Describe your first thoughts on how to solve this problem. --> The problem requires finding the minimum time to traverse a grid where each cell represents a waiting time, and moves alternate between a cost of 1 and 2 units. This can be solved using a modified version of Dijkstra's shortest path algorit...
0
0
['Array', 'Graph', 'Heap (Priority Queue)', 'Matrix', 'Shortest Path', 'C++']
0
find-minimum-time-to-reach-last-room-ii
Djiskira's
djiskiras-by-user0782rf-mnnx
IntuitionApproachComplexity Time complexity: Space complexity: Code
user0782Rf
NORMAL
2025-01-16T06:39:44.289765+00:00
2025-01-16T06:39:44.289765+00:00
3
false
# Intuition If the time so far is less than the timeTomove at the current index, then add the difference tot he time so far. find a way to keep track of what was added last time heap -> distance, node, previous_appended distance -> 2d Grid array of how long it took to reach there ...
0
0
['Python3']
0
find-minimum-time-to-reach-last-room-ii
Modified Dijkstra
modified-dijkstra-by-manmapi-mprw
If we start at "odd" position the fee to travel will be 2, and "even" position will fee 1 to travel.Cost to travel to new position will be the maximum value bet
manmapi
NORMAL
2025-01-15T07:32:12.304385+00:00
2025-01-15T07:32:50.447176+00:00
4
false
If we start at "odd" position the fee to travel will be 2, and "even" position will fee 1 to travel. ```Python fee = 1 + (x + y) % 2 ``` Cost to travel to new position will be the maximum value between previous cost + fee or the minimum time + fee ```Python n_cost = max(A[x_][y_] + fee, cost + fee) ``` The left of c...
0
0
['Python3']
0
find-minimum-time-to-reach-last-room-ii
Simple Dijkistra | beginner friendly
simple-dijkistra-beginner-friendly-by-ak-mi2i
Intuitionthis problem was quite itnutive for me just thoughout of reacing next node if we can reach with current distance otherwise wait at that node as well he
akashsuri
NORMAL
2025-01-13T15:26:53.987957+00:00
2025-01-13T15:26:53.987957+00:00
2
false
# Intuition <!-- Describe your first thoughts on how to solve this problem. --> this problem was quite itnutive for me just thoughout of reacing next node if we can reach with current distance otherwise wait at that node as well here take care of the step and alternate it between the two nodes as well # Approach <!-- ...
0
0
['C++']
0
find-minimum-time-to-reach-last-room-ii
Easy BFS Java solution
easy-bfs-java-solution-by-mayankpathak87-adty
IntuitionThe problem can be likened to a grid-based pathfinding problem where each cell has a cost (represented by moveTime). Our goal is to determine the minim
mayankpathak870
NORMAL
2025-01-04T14:00:30.066612+00:00
2025-01-04T14:00:30.066612+00:00
9
false
# Intuition The problem can be likened to a grid-based pathfinding problem where each cell has a cost (represented by moveTime). Our goal is to determine the minimum time it takes to travel from the top-left corner (0, 0) to the bottom-right corner (m-1, n-1). We are given a matrix, where the time required to move to ...
0
0
['Graph', 'Heap (Priority Queue)', 'Matrix', 'Shortest Path', 'Java']
0
find-minimum-time-to-reach-last-room-ii
Using PriorityQueue, Beats 61%
using-priorityqueue-beats-61-by-poshis-h20a
IntuitionApproachComplexity Time complexity: O(m∗n∗log(m∗n)) Space complexity: O(m∗n) Code
poshis
NORMAL
2024-12-28T08:02:13.127914+00:00
2024-12-28T08:02:13.127914+00:00
7
false
# Intuition <!-- Describe your first thoughts on how to solve this problem. --> # Approach <!-- Describe your approach to solving the problem. --> # Complexity - Time complexity: O(m∗n∗log(m∗n)) <!-- Add your time complexity here, e.g. $$O(n)$$ --> - Space complexity: O(m∗n) <!-- Add your space complexity here, e.g....
0
0
['C#']
0
find-minimum-time-to-reach-last-room-ii
Modified Dijkstra's
modified-dijkstras-by-nraghav5-5rxs
IntuitionApproachComplexity Time complexity: Space complexity: Code
nraghav5
NORMAL
2024-12-25T06:17:14.968351+00:00
2024-12-25T06:17:14.968351+00:00
7
false
# Intuition <!-- Describe your first thoughts on how to solve this problem. --> # Approach <!-- Describe your approach to solving the problem. --> # Complexity - Time complexity: <!-- Add your time complexity here, e.g. $$O(n)$$ --> - Space complexity: <!-- Add your space complexity here, e.g. $$O(n)$$ --> # Code `...
0
0
['C++']
0
find-minimum-time-to-reach-last-room-ii
Modified Dijkstra Algorithm | Beats 96%
modified-dijkstra-algorithm-beats-96-by-8n3lt
Code
adityasharma00070
NORMAL
2024-12-18T08:45:29.159195+00:00
2024-12-18T08:45:29.159195+00:00
5
false
\n\n# Code\n```cpp []\nclass Solution {\npublic:\n int minTimeToReach(vector<vector<int>>& grid) {\n int n=grid.size(),m=grid[0].size();\n priority_queue<pair<int,pair<bool,pair<int,int>>>,vector<pair<int,pair<bool,pair<int,int>>>>,greater<pair<int,pair<bool,pair<int,int>>>>>pq;\n vector<vector<...
0
0
['Array', 'Graph', 'Heap (Priority Queue)', 'Matrix', 'Shortest Path', 'C++']
0
find-minimum-time-to-reach-last-room-ii
C++ || Easy Implementation
c-easy-implementation-by-james_thorn-m7fd
It is just like number of Islands problem using BFS but you have to use priority queue or min heap for the accomodation of weight (time here) and add some more
james_thorn
NORMAL
2024-12-15T11:02:14.172058+00:00
2024-12-15T11:02:14.172058+00:00
3
false
It is just like number of Islands problem using BFS but you have to use priority queue or min heap for the accomodation of weight (time here) and add some more conditions\n\n\n# Complexity\n- Time complexity: O(N * M)log(N * M)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(N*M)\n<!-- A...
0
0
['C++']
0
find-minimum-time-to-reach-last-room-ii
C++ | Dijkstra on Grid | Easy to understand
c-dijkstra-on-grid-easy-to-understand-by-hqoq
Code\ncpp []\nclass Solution {\npublic:\n int minTimeToReach(vector<vector<int>>& moveTime) {\n int n=moveTime.size();\n int m=moveTime[0].size
nroutray
NORMAL
2024-12-04T01:17:52.574909+00:00
2024-12-04T01:17:52.574935+00:00
5
false
# Code\n```cpp []\nclass Solution {\npublic:\n int minTimeToReach(vector<vector<int>>& moveTime) {\n int n=moveTime.size();\n int m=moveTime[0].size();\n vector<pair<int,int>> dir={{0,1},{1,0},{-1,0},{0,-1}};\n priority_queue< pair<pair<int,int>, pair<int,int>>, vector<pair<pair<int,int>,...
0
0
['C++']
0
find-minimum-time-to-reach-last-room-ii
via Priority Queue
via-priority-queue-by-mansoorafzal-kxcg
Complexity\n- Time complexity:\nO((n * m).log(n * m))\n\n- Space complexity:\nO(n * m)\n\n# Code\ncsharp []\npublic class Solution {\n public int MinTimeToRe
mansoorafzal
NORMAL
2024-11-29T17:01:48.065616+00:00
2024-11-29T17:01:48.065663+00:00
6
false
# Complexity\n- Time complexity:\n$$O((n * m).log(n * m))$$\n\n- Space complexity:\n$$O(n * m)$$\n\n# Code\n```csharp []\npublic class Solution {\n public int MinTimeToReach(int[][] moveTime) {\n int n = moveTime.Length;\n int m = moveTime[0].Length;\n\n HashSet<(int, int)> directions = new Hash...
0
0
['Graph', 'Heap (Priority Queue)', 'Shortest Path', 'C#']
0
find-minimum-time-to-reach-last-room-ii
Minimum Time To Reach Last Room II !100% Beat CPP
minimum-time-to-reach-last-room-ii-100-b-gyry
Intuition\n\nThe problem at hand seems to be a pathfinding challenge where you need to calculate the minimum time to traverse a grid, starting from the top-left
Gopi_C_K
NORMAL
2024-11-29T13:03:13.044667+00:00
2024-11-29T13:03:13.044708+00:00
6
false
### Intuition\n\nThe problem at hand seems to be a pathfinding challenge where you need to calculate the minimum time to traverse a grid, starting from the top-left corner `(0, 0)` and ending at the bottom-right corner `(m-1, n-1)`. Each cell in the grid has a "time" value that could affect your movement through it. Th...
0
0
['Array', 'Graph', 'Heap (Priority Queue)', 'Shortest Path', 'C++']
0
find-minimum-time-to-reach-last-room-ii
Easy Djikstra solution
easy-djikstra-solution-by-pipilongstocki-ax4u
Code\npython3 []\nclass Solution:\n def minTimeToReach(self, moveTime: List[List[int]]) -> int:\n m, n = len(moveTime), len(moveTime[0])\n dirs
pipilongstocking
NORMAL
2024-11-29T09:31:23.686946+00:00
2024-11-29T09:31:23.686985+00:00
4
false
# Code\n```python3 []\nclass Solution:\n def minTimeToReach(self, moveTime: List[List[int]]) -> int:\n m, n = len(moveTime), len(moveTime[0])\n dirs = [[1,0],[-1,0],[0,1],[0,-1]]\n times = [[inf] * n for _ in range(m)]\n times[0][0] = 0\n min_heap = [[0, 0, 0, 1]]\n\n while ...
0
0
['Heap (Priority Queue)', 'Shortest Path', 'Python3']
0
find-minimum-time-to-reach-last-room-ii
Solved using modified Dijkstra's algorithm in cpp beating 98 % solutions.
solved-using-modified-dijkstras-algorith-7jzg
Intuition\nThe given solution uses a priority queue to implement a modified Dijkstra\'s algorithm for finding the minimum time to reach the bottom-right corner
ankitsharma1145
NORMAL
2024-11-29T07:33:11.480182+00:00
2024-11-29T07:33:11.480207+00:00
5
false
# Intuition\nThe given solution uses a priority queue to implement a modified Dijkstra\'s algorithm for finding the minimum time to reach the bottom-right corner of a grid, where the time taken to move depends on the number of steps taken.\n\n\n# Complexity\n- Time complexity:\n1. The algorithm processes each cell in t...
0
0
['C++']
0
find-minimum-time-to-reach-last-room-ii
Python | C++ Dijkstra
python-c-dijkstra-by-kaluginpeter-9wqr
\n\n# Complexity\n- Time complexity: O(ElogE)\n\n- Space complexity: O(ElogE)\n\n# Code\npython []\nclass Solution:\n def minTimeToReach(self, moveTime: List
kaluginpeter
NORMAL
2024-11-26T17:46:05.779294+00:00
2024-11-26T17:46:05.779335+00:00
0
false
\n\n# Complexity\n- Time complexity: O(ElogE)\n\n- Space complexity: O(ElogE)\n\n# Code\n```python []\nclass Solution:\n def minTimeToReach(self, moveTime: List[List[int]]) -> int:\n m, n = len(moveTime), len(moveTime[0])\n pq: list[tuple[int]] = [(0, 0, 0, 0)]\n min_time: list[list[int]] = [[fl...
0
0
['Array', 'Graph', 'Heap (Priority Queue)', 'Matrix', 'Shortest Path', 'C++', 'Python3']
0
find-minimum-time-to-reach-last-room-ii
Java | JavaScript | TypeScript | C++ | C# | Kotlin | Go Solution.
java-javascript-typescript-c-c-kotlin-go-926p
Java []\nimport java.util.Arrays;\nimport java.util.PriorityQueue;\n\npublic class Solution {\n\n private record Step(int row, int column, int timeToMoveBetw
LachezarTsK
NORMAL
2024-11-25T05:21:39.908502+00:00
2024-11-25T05:26:43.192835+00:00
10
false
```Java []\nimport java.util.Arrays;\nimport java.util.PriorityQueue;\n\npublic class Solution {\n\n private record Step(int row, int column, int timeToMoveBetweenTwoPoints, int timeFromStart) {}\n\n private static final int[] UP = {-1, 0};\n private static final int[] DOWN = {1, 0};\n private static final ...
0
0
['C++', 'Java', 'Go', 'TypeScript', 'Kotlin', 'JavaScript', 'C#']
0
find-minimum-time-to-reach-last-room-ii
Simple Java Solution
simple-java-solution-by-sakshikishore-z65e
Code\njava []\nclass Node\n{\n int a,b;\n public Node(int i,int j)\n {\n a=i;\n b=j;\n }\n}\nclass Solution {\n public int minTimeToR
sakshikishore
NORMAL
2024-11-22T05:11:41.967828+00:00
2024-11-22T05:11:41.967868+00:00
2
false
# Code\n```java []\nclass Node\n{\n int a,b;\n public Node(int i,int j)\n {\n a=i;\n b=j;\n }\n}\nclass Solution {\n public int minTimeToReach(int[][] moveTime) {\n int visited[][]=new int[moveTime.length][moveTime[0].length];\n int f[][]=new int[moveTime.length][moveTime[0].len...
0
0
['Java']
0
find-minimum-time-to-reach-last-room-ii
Java : Two Queue Dijkstra Solution
java-two-queue-dijkstra-solution-by-anur-w7eb
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,
anuraganand789
NORMAL
2024-11-21T13:44:03.374007+00:00
2024-11-21T13:44:03.374039+00:00
2
false
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.leng...
0
0
['Shortest Path', 'Java']
0
find-minimum-time-to-reach-last-room-ii
[C++] Dijkstra's Algorithm
c-dijkstras-algorithm-by-enniggma-sgwn
Code\ncpp []\nclass Solution {\npublic:\n int dx[4] = {-1, 1, 0, 0};\n int dy[4] = {0, 0, -1, 1};\n const long long INF = 1e15;\n int minTimeToReach
AwakenX
NORMAL
2024-11-14T18:07:10.246680+00:00
2024-11-14T18:07:10.246723+00:00
3
false
# Code\n```cpp []\nclass Solution {\npublic:\n int dx[4] = {-1, 1, 0, 0};\n int dy[4] = {0, 0, -1, 1};\n const long long INF = 1e15;\n int minTimeToReach(vector<vector<int>>& arr) {\n int n = arr.size();\n int m = arr[0].size();\n priority_queue<pair<int, pair<pair<int, int>, int>>, vec...
0
0
['C++']
0
find-minimum-time-to-reach-last-room-ii
Dijkstra's algo
dijkstras-algo-by-up41guy-6jpm
javascript []\nclass MinMaxPriorityQueue {\n\n #heap = []\n #compare;\n\n constructor(compare) {\n this.#heap = [];\n this.#compare = compare || ((a, b
Cx1z0
NORMAL
2024-11-13T15:00:33.843868+00:00
2024-11-13T15:00:33.843903+00:00
3
false
```javascript []\nclass MinMaxPriorityQueue {\n\n #heap = []\n #compare;\n\n constructor(compare) {\n this.#heap = [];\n this.#compare = compare || ((a, b) => a - b) //By default, keep it MinHeap\n }\n\n // Add a new element to the priority queue\n enqueue = (value) => {\n this.#heap.push(value);\n th...
0
0
['Array', 'Graph', 'Heap (Priority Queue)', 'Matrix', 'Shortest Path', 'JavaScript']
0
find-minimum-time-to-reach-last-room-ii
Dijkstra's algo
dijkstras-algo-by-up41guy-1rno
javascript []\nclass MinMaxPriorityQueue {\n\n #heap = []\n #compare;\n\n constructor(compare) {\n this.#heap = [];\n this.#compare = compare || ((a, b
Cx1z0
NORMAL
2024-11-13T14:59:55.006387+00:00
2024-11-13T14:59:55.006423+00:00
0
false
```javascript []\nclass MinMaxPriorityQueue {\n\n #heap = []\n #compare;\n\n constructor(compare) {\n this.#heap = [];\n this.#compare = compare || ((a, b) => a - b) //By default, keep it MinHeap\n }\n\n // Add a new element to the priority queue\n enqueue = (value) => {\n this.#heap.push(value);\n th...
0
0
['Array', 'Graph', 'Heap (Priority Queue)', 'Matrix', 'Shortest Path', 'JavaScript']
0
find-minimum-time-to-reach-last-room-ii
Heap/PriorityQueue || Java || Dijkstra || Clean code
heappriorityqueue-java-dijkstra-clean-co-fvjv
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
owaispatel95
NORMAL
2024-11-13T07:33:54.900153+00:00
2024-11-13T07:33:54.900177+00:00
4
false
# 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)$$ --...
0
0
['Java']
0
find-minimum-time-to-reach-last-room-ii
Easy BFS ✅
easy-bfs-by-vedantagrawal524-cytc
Code\ncpp []\nclass Solution {\npublic:\n int dr[4]={-1,1,0,0};\n int dc[4]={0,0,-1,1};\n int bfs(vector<vector<int>>& moveTime,int n,int m,vector<vect
vedantagrawal524
NORMAL
2024-11-12T10:42:47.110166+00:00
2024-11-12T10:42:47.110200+00:00
5
false
# Code\n```cpp []\nclass Solution {\npublic:\n int dr[4]={-1,1,0,0};\n int dc[4]={0,0,-1,1};\n int bfs(vector<vector<int>>& moveTime,int n,int m,vector<vector<int>>& time){\n priority_queue<vector<int>,vector<vector<int>>,greater<vector<int>>>q;\n q.push({0,0,0,0});\n time[0][0]=0;\n ...
0
0
['Array', 'Breadth-First Search', 'Graph', 'Heap (Priority Queue)', 'Matrix', 'Shortest Path', 'C++']
0
find-minimum-time-to-reach-last-room-ii
Simple Solution beats 100% using priority queue
simple-solution-beats-100-using-priority-8ka8
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
vikash_kumar_dsa2
NORMAL
2024-11-12T07:45:45.403258+00:00
2024-11-12T07:45:45.403302+00:00
3
false
# 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)$$ --...
0
0
['Array', 'Graph', 'Heap (Priority Queue)', 'Matrix', 'Shortest Path', 'C++']
0
find-minimum-time-to-reach-last-room-ii
using priority queue
using-priority-queue-by-aartik001-2jlg
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
aartik001
NORMAL
2024-11-11T21:00:02.146887+00:00
2024-11-11T21:00:02.146926+00:00
4
false
# 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)$$ --...
0
0
['Heap (Priority Queue)', 'C++']
0
find-minimum-time-to-reach-last-room-ii
[scala] - Dijkstra, immutable, recursion
scala-dijkstra-immutable-recursion-by-ni-xq9s
I am deeply concerned by the amount of attention given to Scala. Please upvote and submit your solutions.\n\n# Code\nscala []\nobject Solution {\n import scala
nikiforo
NORMAL
2024-11-09T19:58:19.097884+00:00
2024-11-09T19:58:19.097912+00:00
4
false
I am deeply concerned by the amount of attention given to Scala. Please upvote and submit your solutions.\n\n# Code\n```scala []\nobject Solution {\n import scala.collection.immutable.TreeSet\n\n def minTimeToReach(moveTime: Array[Array[Int]]): Int = {\n def inBorder(c: (Int, Int)) = c._1 >= 0 && c._1 < moveTime.l...
0
0
['Scala']
0
find-minimum-time-to-reach-last-room-ii
modified Dijkstra (strivers solution is modifed)
modified-dijkstra-strivers-solution-is-m-ku6e
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
sangdilcompetes
NORMAL
2024-11-09T17:02:32.873615+00:00
2024-11-09T17:02:32.873642+00:00
6
false
# 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)$$ --...
0
0
['C++']
0
find-minimum-time-to-reach-last-room-ii
C++ 250 ms
c-250-ms-by-eridanoy-k1a3
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
eridanoy
NORMAL
2024-11-09T17:02:07.831724+00:00
2024-11-09T17:02:07.831756+00:00
3
false
# 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)$$ --...
0
0
['C++']
0
find-minimum-time-to-reach-last-room-ii
Dijkstra Alg Easy
dijkstra-alg-easy-by-gps_357-zuyo
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
gps_357
NORMAL
2024-11-08T13:57:29.186826+00:00
2024-11-08T13:57:29.186857+00:00
3
false
# 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)$$ --...
0
0
['C++']
0
find-minimum-time-to-reach-last-room-ii
Using Dijstra algorithm 100% faster solution
using-dijstra-algorithm-100-faster-solut-dcmh
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
Balram_54321
NORMAL
2024-11-08T10:07:51.955368+00:00
2024-11-08T10:07:51.955389+00:00
5
false
# 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...
0
0
['C++']
0
find-minimum-time-to-reach-last-room-ii
Dijkstra's
dijkstras-by-lambdacode-dev-gpsn
Intuition\n- No significant change to version I problem. just add move time step to the state variable.\n\n \n# Code\ncpp []\nclass Solution {\npublic:\n int
lambdacode-dev
NORMAL
2024-11-07T22:23:22.897595+00:00
2024-11-07T22:23:22.897627+00:00
1
false
# Intuition\n- No significant change to version I problem. just add move time step to the state variable.\n\n \n# Code\n```cpp []\nclass Solution {\npublic:\n int minTimeToReach(vector<vector<int>>& moveTime) {\n int rows = moveTime.size(), cols = moveTime[0].size();\n using State = array<int,4>; // (t...
0
0
['C++']
0
find-minimum-time-to-reach-last-room-ii
Dijsktra's || C++
dijsktras-c-by-lotus18-mkpt
Code\ncpp []\nclass Solution \n{\npublic:\n bool valid(int r, int c, int rows, int cols)\n {\n return (r>=0 && r<rows && c>=0 && c<cols);\n }\n
lotus18
NORMAL
2024-11-06T10:19:29.510266+00:00
2024-11-06T10:19:29.510296+00:00
2
false
# Code\n```cpp []\nclass Solution \n{\npublic:\n bool valid(int r, int c, int rows, int cols)\n {\n return (r>=0 && r<rows && c>=0 && c<cols);\n }\n int minTimeToReach(vector<vector<int>>& moveTime) \n {\n int rows=moveTime.size(), cols=moveTime[0].size();\n priority_queue<vector<int...
0
0
['Graph', 'Heap (Priority Queue)', 'Shortest Path', 'C++']
0
find-minimum-time-to-reach-last-room-ii
Modified Dijkshtra's Algorithm
modified-dijkshtras-algorithm-by-siddhar-f8u2
Intuition\nThink of standing at $currentPosition$ and you have 4 possible directions to move. If you took $cost$ time to reach to a point where you are currentl
siddharthraja9849
NORMAL
2024-11-06T03:52:36.269979+00:00
2024-11-06T03:52:36.270003+00:00
12
false
# Intuition\nThink of standing at $currentPosition$ and you have 4 possible directions to move. If you took $cost$ time to reach to a point where you are currently and you can move from $currentPosition$ to the $nextPosition$ using a $nextCost$ would you move if earlier you already visited the $nextPosition$ with some ...
0
0
['Graph', 'Heap (Priority Queue)', 'Matrix', 'Shortest Path', 'C++']
0
find-minimum-time-to-reach-last-room-ii
Dijkstra's Algorithm
dijkstras-algorithm-by-rancha124-h8v6
\nclass Solution:\n def minTimeToReach(self, moveTime: List[List[int]]) -> int:\n import heapq\n m, n = len(moveTime), len(moveTime[0])\n
Rancha124
NORMAL
2024-11-06T01:38:57.419811+00:00
2024-11-06T01:38:57.419847+00:00
14
false
```\nclass Solution:\n def minTimeToReach(self, moveTime: List[List[int]]) -> int:\n import heapq\n m, n = len(moveTime), len(moveTime[0])\n heap = []\n\t\t# state could be 0 (1 sec to reach adjacent cell) or 1 (2 sec to reach adjacent cell)\n heapq.heappush(heap, (0, 0, 0, 0)) # minTime ...
0
0
['Python']
0
find-minimum-time-to-reach-last-room-ii
Modified Dijkstra with Clear Data Structure Definition
modified-dijkstra-with-clear-data-struct-d4k2
Intuition\nBased on the fact that there may be a gap build by large enter time limit, it\'s easy to see that standard DFS/BFS mechanism may not work well, as a
xpressz
NORMAL
2024-11-05T23:30:07.405189+00:00
2024-11-05T23:30:07.405233+00:00
10
false
# Intuition\nBased on the fact that there may be a gap build by large enter time limit, it\'s easy to see that standard DFS/BFS mechanism may not work well, as a "detour" may be welcomed. Example:\n\n```\n[\n [0, 100, 0, 0, 0],\n [0, 0, 0, 100, 0]\n]\n```\n\nThe path would go in a strange way, with down step firs...
0
0
['Python3']
0
find-minimum-time-to-reach-last-room-ii
C++ | Dijkstra
c-dijkstra-by-pikachuu-oul3
Code\ncpp []\nclass Solution {\n struct comp {\n bool operator()(auto &A, auto &B) {\n return A.first > B.first;\n }\n };\npublic
pikachuu
NORMAL
2024-11-05T21:09:15.495084+00:00
2024-11-05T21:09:15.495110+00:00
2
false
# Code\n```cpp []\nclass Solution {\n struct comp {\n bool operator()(auto &A, auto &B) {\n return A.first > B.first;\n }\n };\npublic:\n int minTimeToReach(vector<vector<int>>& moveTime) {\n priority_queue<pair<int, vector<int>>, vector<pair<int, vector<int>>>, comp> PQ;\n ...
0
0
['Graph', 'Heap (Priority Queue)', 'Matrix', 'Shortest Path', 'C++']
0
find-minimum-time-to-reach-last-room-ii
Can someone please explain why this solution is getting TLE?
can-someone-please-explain-why-this-solu-578a
\nq=[]\nheapq.heapify(q)\nheapq.heappush(q,[0,0,0,True])\nm=len(moveTime)\nn=len(moveTime[0])\nans=[[float(\'inf\') for i in range(n)] for j in range(m)]\nwhile
Varad
NORMAL
2024-11-05T13:37:18.195653+00:00
2024-11-05T13:37:18.195684+00:00
11
false
```\nq=[]\nheapq.heapify(q)\nheapq.heappush(q,[0,0,0,True])\nm=len(moveTime)\nn=len(moveTime[0])\nans=[[float(\'inf\') for i in range(n)] for j in range(m)]\nwhile(len(q)>0):\n i,j,wt,pre=heapq.heappop(q)\n\n ans[i][j]=min(ans[i][j],wt)\n if i+1<m :\n if pre==True:\n tmp=max(0,moveTime[i+1][j...
0
0
[]
0
find-minimum-time-to-reach-last-room-ii
Using Priority_Queue || C++
using-priority_queue-c-by-vijay_kunigiri-i9hs
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
vijay_kunigiri17
NORMAL
2024-11-05T13:33:09.987423+00:00
2024-11-05T13:33:09.987457+00:00
12
false
# 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)$$ --...
0
0
['C++']
0
find-minimum-time-to-reach-last-room-ii
[C++] Dijkstra.
c-dijkstra-by-lovebaonvwu-ys47
\ncpp []\nclass Solution {\npublic:\n int minTimeToReach(vector<vector<int>>& moveTime) {\n int n = moveTime.size();\n int m = moveTime[0].size
lovebaonvwu
NORMAL
2024-11-05T01:07:38.720649+00:00
2024-11-05T01:07:38.720694+00:00
1
false
\n```cpp []\nclass Solution {\npublic:\n int minTimeToReach(vector<vector<int>>& moveTime) {\n int n = moveTime.size();\n int m = moveTime[0].size();\n\n priority_queue<array<int, 4>, vector<array<int, 4>>, greater<>> pq;\n pq.push({0, 0, 0, 1});\n vector<vector<int>> arriveAt(n, v...
0
0
['C++']
0
find-minimum-time-to-reach-last-room-ii
Swift Solution using Dijkstra's
swift-solution-using-dijkstras-by-liampr-po9j
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
liampronan
NORMAL
2024-11-04T20:37:25.531172+00:00
2024-11-04T20:37:25.531204+00:00
4
false
# 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: $$O(nm*log(nm))$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(n*m)$$\n<!-- Add your space com...
0
0
['Swift']
0
find-minimum-time-to-reach-last-room-ii
PriorityQueue to track the min time used till current location
priorityqueue-to-track-the-min-time-used-jowr
Intuition\n Describe your first thoughts on how to solve this problem. \ncorrectly understand the meaning of "alternating between the two." is the core part of
linda2024
NORMAL
2024-11-04T20:19:36.901378+00:00
2024-11-04T20:19:36.901415+00:00
6
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\ncorrectly understand the meaning of "alternating between the two." is the core part of this question.\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity ...
0
0
['C#']
0
find-minimum-time-to-reach-last-room-ii
Dijkstra | C++
dijkstra-c-by-siddharth96shukla-2v3t
Complexity\n- Time complexity: O(nm*log(nm))\n Add your time complexity here, e.g. O(n) \n\n# Code\ncpp []\n#define ll long long int\n\nclass Solution {\npublic
siddharth96shukla
NORMAL
2024-11-04T17:52:26.547639+00:00
2024-11-04T17:52:26.547675+00:00
14
false
# Complexity\n- Time complexity: $$O(nm*log(nm))$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```cpp []\n#define ll long long int\n\nclass Solution {\npublic:\n int dr[4] = {0, 1, 0, -1};\n int dc[4] = {1, 0, -1, 0};\n\n int minTimeToReach(vector<vector<int>>& mt) {\n int n=mt.siz...
0
0
['Shortest Path', 'C++']
0
find-minimum-time-to-reach-last-room-ii
Easy and intutive solution
easy-and-intutive-solution-by-coolcoder2-106d
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
coolcoder251
NORMAL
2024-11-04T17:33:20.784189+00:00
2024-11-04T17:33:20.784230+00:00
7
false
# 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)$$ --...
0
0
['C++']
0
find-minimum-time-to-reach-last-room-ii
Djkistra Algorithm
djkistra-algorithm-by-stwik_back-oaxr
Intuition\nFirst thoght is of Dynamic programming.But it is very Compliacted because we have four directions to move so there is a possibility of cycle and if w
stwik_back
NORMAL
2024-11-04T17:17:46.753428+00:00
2024-11-04T17:17:46.753468+00:00
23
false
# Intuition\nFirst thoght is of Dynamic programming.But it is very Compliacted because we have four directions to move so there is a possibility of cycle and if we do dp we need to handle the cycle also. so think of graph algorithms.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nso the approac...
0
0
['Graph', 'Java']
0
find-minimum-time-to-reach-last-room-ii
Simple bfs solution
simple-bfs-solution-by-risabhuchiha-pi0u
\njava []\nclass Solution {\n public int minTimeToReach(int[][] m) {\n PriorityQueue<int[]>pq=new PriorityQueue<>((a,b)->a[2]-b[2]);\n pq.off
risabhuchiha
NORMAL
2024-11-04T14:25:28.948285+00:00
2024-11-04T14:25:28.948315+00:00
6
false
\n```java []\nclass Solution {\n public int minTimeToReach(int[][] m) {\n PriorityQueue<int[]>pq=new PriorityQueue<>((a,b)->a[2]-b[2]);\n pq.offer(new int[]{0,0,0,0});\n int[][]vis=new int[m.length][m[0].length];\n int[]dr=new int[]{0,1,0,-1};\n int[]dc=new int[]{1,0,-1,0};\n ...
0
0
['Java']
0
find-minimum-time-to-reach-last-room-ii
Explanation for bigenners | Dikstra using priority queue
explanation-for-bigenners-dikstra-using-bufkb
Approach\n Describe your approach to solving the problem. \n## 1. Problem Setup\nYou\u2019re given a grid (mt) where each cell has a time requirement. You need
goku_monkey
NORMAL
2024-11-04T14:22:59.631816+00:00
2024-11-04T14:22:59.631855+00:00
7
false
# Approach\n<!-- Describe your approach to solving the problem. -->\n## 1. Problem Setup\nYou\u2019re given a grid (mt) where each cell has a time requirement. You need to find the minimum time to reach the bottom-right corner from the top-left corner, but you may have to wait if the time isn\u2019t right to move to a ...
0
0
['C++']
0
find-minimum-time-to-reach-last-room-ii
Beats 100%(Easy to understand)
beats-100easy-to-understand-by-ayushjha1-wn5e
Intuition\nSame as Previos question just apply step logic\n# Approach\nMaintain a third variable for step and toggle it between 1 and 2 which can be done as 3-s
ayushjha11
NORMAL
2024-11-04T13:29:32.397026+00:00
2024-11-04T13:29:32.397070+00:00
4
false
# Intuition\nSame as Previos question just apply step logic\n# Approach\nMaintain a third variable for step and toggle it between 1 and 2 which can be done as 3-step\n\n# Complexity\n- Time complexity:\nO(N\u2217M\u2217Log(N+M))\n\n- Space complexity:\nO(N\u2217M)\n\n# Code\n```cpp []\nclass Solution {\npublic:\n in...
0
0
['C++']
0
find-minimum-time-to-reach-last-room-ii
beat 100%||classical dijkstra algorithm
beat-100classical-dijkstra-algorithm-by-l3bly
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
sachinkumar993426
NORMAL
2024-11-04T13:12:12.833898+00:00
2024-11-04T13:12:12.833942+00:00
3
false
# 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)$$ --...
0
0
['C++']
0
find-minimum-time-to-reach-last-room-ii
Dijkstra Algo | Easy | C++ | Beats 90% | Graph
dijkstra-algo-easy-c-beats-90-graph-by-b-vym7
\n# Code\ncpp []\nclass Solution {\npublic:\n int minTimeToReach(vector<vector<int>>& moveTime) {\n int m = moveTime.size();\n int n = moveTime
bkbkbhavyakalra
NORMAL
2024-11-04T12:25:45.501230+00:00
2024-11-04T12:25:45.501255+00:00
4
false
\n# Code\n```cpp []\nclass Solution {\npublic:\n int minTimeToReach(vector<vector<int>>& moveTime) {\n int m = moveTime.size();\n int n = moveTime[0].size();\n priority_queue<pair<int,vector<int>>, vector<pair<int,vector<int>>>, greater<pair<int,vector<int>>>> pq;\n vector<vector<int>> ch...
0
0
['Array', 'Graph', 'Matrix', 'C++']
0
find-minimum-time-to-reach-last-room-ii
Concise and easiy to follow solution using dp and heap
concise-and-easiy-to-follow-solution-usi-5art
Intuition\nInspired by many solutions from question: Find Minimum Time to Reach Last Room I\n\n# Approach\nUsing minheap to follow the path that has minimum tim
nguyenhuuthai
NORMAL
2024-11-04T11:45:29.486040+00:00
2024-11-04T11:45:29.486064+00:00
10
false
# Intuition\nInspired by many solutions from question: [Find Minimum Time to Reach Last Room I](https://leetcode.com/problems/find-minimum-time-to-reach-last-room-i/description/)\n\n# Approach\nUsing minheap to follow the path that has minimum time\nUsing dp to store the minimum time to get to a specific node(dungeon)\...
0
0
['Python3']
0
find-minimum-time-to-reach-last-room-ii
Dijkstra
dijkstra-by-user5285zn-ylyd
rust []\nuse std::collections::BinaryHeap;\nuse std::cmp::Reverse;\n\nimpl Solution {\n pub fn min_time_to_reach(move_time: Vec<Vec<i32>>) -> i32 {\n
user5285Zn
NORMAL
2024-11-04T10:52:41.959964+00:00
2024-11-04T10:52:41.959990+00:00
6
false
```rust []\nuse std::collections::BinaryHeap;\nuse std::cmp::Reverse;\n\nimpl Solution {\n pub fn min_time_to_reach(move_time: Vec<Vec<i32>>) -> i32 {\n let n = move_time.len();\n let m = move_time[0].len();\n let mut q = BinaryHeap::new();\n let mut seen = vec![vec![false; m]; n];\n ...
0
0
['Rust']
0
find-minimum-time-to-reach-last-room-ii
Djikstra Solution.
djikstra-solution-by-arif2321-wl8l
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
Arif2321
NORMAL
2024-11-04T10:21:29.804573+00:00
2024-11-04T10:21:29.804606+00:00
2
false
# 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)$$ --...
0
0
['C++']
0
find-minimum-time-to-reach-last-room-ii
JAVA solution with simple calculation of moving time
java-solution-with-simple-calculation-of-ae24
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
meringueee
NORMAL
2024-11-04T10:15:21.488777+00:00
2024-11-04T10:15:21.488799+00:00
7
false
# 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 compl...
0
0
['Java']
0
find-minimum-time-to-reach-last-room-ii
JAVA DP + PQ SOLUTION
java-dp-pq-solution-by-divyansh_2069-hu4m
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
divyansh_2069
NORMAL
2024-11-04T09:13:06.746644+00:00
2024-11-04T09:13:06.746669+00:00
6
false
# 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)$$ --...
0
0
['Java']
0
find-minimum-time-to-reach-last-room-ii
BFS | Min Heap | 100% (Space & Time)
bfs-min-heap-100-space-time-by-hieuwu-8uqq
Recommended problems to get familiar with BFS & Min Heap\n\n3341. Find Minimum Time to Reach Last Room I\n2577. Minimum Time to Visit a Cell In a Grid\n\n# Intu
hieuwu
NORMAL
2024-11-04T08:02:18.955652+00:00
2024-11-04T08:02:18.955681+00:00
22
false
Recommended problems to get familiar with BFS & Min Heap\n\n[3341. Find Minimum Time to Reach Last Room I](https://leetcode.com/problems/find-minimum-time-to-reach-last-room-i/)\n[2577. Minimum Time to Visit a Cell In a Grid](https://leetcode.com/problems/minimum-time-to-visit-a-cell-in-a-grid)\n\n# Intuition\n<!-- Des...
0
0
['Breadth-First Search', 'Heap (Priority Queue)', 'Python3']
0
find-minimum-time-to-reach-last-room-ii
Solution using Dijkstra Algorithm
solution-using-dijkstra-algorithm-by-adi-hvdl
\n# Code\npython3 []\nclass Solution:\n # solved using dijkstra\'s algorithm, Time complexity: O(Elog(V))\n def minTimeToReach(self, moveTime: List[List[i
adityabhattad18
NORMAL
2024-11-04T07:03:23.634616+00:00
2024-11-04T07:03:23.634652+00:00
14
false
\n# Code\n```python3 []\nclass Solution:\n # solved using dijkstra\'s algorithm, Time complexity: O(Elog(V))\n def minTimeToReach(self, moveTime: List[List[int]]) -> int:\n ROW,COL = len(moveTime), len(moveTime[0])\n directions = [\n (-1,0),\n (1,0),\n (0,-1),\n ...
0
0
['Python3']
0