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
binary-prefix-divisible-by-5
c++ solution with explaination of modulo
c-solution-with-explaination-of-modulo-b-xtqr
Let say we have "011111". It produces 0, 1, 3, 7, 15, 31 . If we track modulo instead, we will have 0, 1, 3, 2, 0, 1 so the result is the same. we are interest
Astrophile_M
NORMAL
2021-05-29T14:37:35.203688+00:00
2021-05-29T14:37:35.203723+00:00
82
false
Let say we have "011111". It produces 0, 1, 3, 7, 15, 31 . If we track modulo instead, we will have 0, 1, 3, 2, 0, 1 so the result is the same. we are interested if our number is divisible by 5 or not. So to stop the overflow, modulo will make the number smaller and answer remain same. \n```\nclass Solution {\npublic:...
1
0
['C++']
0
binary-prefix-divisible-by-5
Fast and Simple C++
fast-and-simple-c-by-arpit_sat-279e
\nvector<bool> prefixesDivBy5(vector<int>& A) {\n\tint val=0;\n\tvector<bool> res(A.size());\n\tfor(int i=0;i<A.size();i++)\n\t{\n\t\tval=val*2+A[i];\n\t\tif(va
Arpit_Sat
NORMAL
2021-04-04T17:41:49.206153+00:00
2021-04-04T17:41:49.206193+00:00
117
false
```\nvector<bool> prefixesDivBy5(vector<int>& A) {\n\tint val=0;\n\tvector<bool> res(A.size());\n\tfor(int i=0;i<A.size();i++)\n\t{\n\t\tval=val*2+A[i];\n\t\tif(val%5==0)\n\t\t\tres[i]=true;\n\t\tval=val%5;\n\t}\n\treturn res;\n}\n```
1
0
[]
0
binary-prefix-divisible-by-5
Easy python3 implementation
easy-python3-implementation-by-zwerhu-yqd0
isDivisible = [False for i in range(len(A))]\n result = A[0]\n isDivisible[0] = True if result % 5 == 0 else False \n for i in range(1, len
zwerhu
NORMAL
2021-04-03T22:49:18.106431+00:00
2021-04-03T22:49:18.106477+00:00
78
false
isDivisible = [False for i in range(len(A))]\n result = A[0]\n isDivisible[0] = True if result % 5 == 0 else False \n for i in range(1, len(A)):\n result = 2 * result + A[i]\n isDivisible[i] = True if result % 5 == 0 else False \n \n return isDivisible\n
1
0
[]
0
binary-prefix-divisible-by-5
c++(4ms 99,80%) bit manipulation (with comments)
c4ms-9980-bit-manipulation-with-comments-8asm
Runtime: 4 ms, faster than 99.80% of C++ online submissions for Binary Prefix Divisible By 5.\nMemory Usage: 13.9 MB, less than 62.92% of C++ online submissions
zx007pi
NORMAL
2021-03-21T20:27:59.555780+00:00
2021-03-21T20:27:59.555815+00:00
152
false
Runtime: 4 ms, faster than 99.80% of C++ online submissions for Binary Prefix Divisible By 5.\nMemory Usage: 13.9 MB, less than 62.92% of C++ online submissions for Binary Prefix Divisible By 5.\n```\nclass Solution {\npublic:\n vector<bool> prefixesDivBy5(vector<int>& A) {\n vector<bool> ans;\n unsigned long re...
1
0
['C', 'C++']
1
binary-prefix-divisible-by-5
Time O(n) Space O(1) Python3 solution
time-on-space-o1-python3-solution-by-mhv-h5d8
\n\nclass Solution:\n def prefixesDivBy5(self, A: List[int]) -> List[bool]:\n # time O(n)\n # space O(1)\n output = []\n last_bit
mhviraf
NORMAL
2021-02-11T03:21:52.064771+00:00
2021-02-11T03:22:07.865139+00:00
136
false
\n```\nclass Solution:\n def prefixesDivBy5(self, A: List[int]) -> List[bool]:\n # time O(n)\n # space O(1)\n output = []\n last_bit = 0\n for i in range(len(A)):\n new_bit = last_bit*2 + A[i]\n output.append(new_bit % 5 == 0)\n last_bit = new_bit\n...
1
0
['Python', 'Python3']
0
binary-prefix-divisible-by-5
Easy C++ Binary Prefix Divisible By 5
easy-c-binary-prefix-divisible-by-5-by-r-g390
Naive Solution\nRefrence - https://leetcode.com/problems/binary-prefix-divisible-by-5/discuss/265601/Detailed-Explanation-using-Modular-Arithmetic-O(n)\n\n\ncla
rajawatbanna
NORMAL
2021-01-22T06:27:03.298766+00:00
2021-01-22T06:27:03.298810+00:00
147
false
# Naive Solution\nRefrence - https://leetcode.com/problems/binary-prefix-divisible-by-5/discuss/265601/Detailed-Explanation-using-Modular-Arithmetic-O(n)\n\n```\nclass Solution {\npublic:\n vector<bool> prefixesDivBy5(vector<int>& A) {\n vector<bool> lks;\n int n=0;\n for(auto x:A){\n ...
1
0
['C']
0
binary-prefix-divisible-by-5
Java Solution
java-solution-by-suruchigarg12-a1cd
\nclass Solution {\n public List<Boolean> prefixesDivBy5(int[] A) {\n int n = 0;\n List<Boolean> ans = new ArrayList<>();\n \n fo
suruchigarg12
NORMAL
2020-12-07T04:02:40.528957+00:00
2020-12-07T04:02:40.529001+00:00
173
false
```\nclass Solution {\n public List<Boolean> prefixesDivBy5(int[] A) {\n int n = 0;\n List<Boolean> ans = new ArrayList<>();\n \n for(int num : A){\n n += num;\n ans.add(n%5 == 0);\n n = n*2;\n n = n%5;\n }\n \n return ans;\...
1
0
[]
0
binary-prefix-divisible-by-5
c++ solution easy
c-solution-easy-by-dilipsuthar60-9glw
\nclass Solution {\npublic:\n vector<bool> prefixesDivBy5(vector<int>& A) \n {\n vector<bool>v;\n int n=A.size();\n int num=A[0];\n
dilipsuthar17
NORMAL
2020-11-24T08:42:41.114845+00:00
2020-11-24T08:42:41.114873+00:00
197
false
```\nclass Solution {\npublic:\n vector<bool> prefixesDivBy5(vector<int>& A) \n {\n vector<bool>v;\n int n=A.size();\n int num=A[0];\n if(num%5==0)\n {\n v.push_back(true);\n }\n else\n {\n v.push_back(false);\n }\n for(in...
1
0
[]
0
binary-prefix-divisible-by-5
Java | Modular Arithmetic
java-modular-arithmetic-by-rajarshi-sark-6h0s
\nclass Solution {\n public List<Boolean> prefixesDivBy5(int[] A) {\n int n = 0;\n List<Boolean> answer = new ArrayList<>();\n \n
rajarshi-sarkar
NORMAL
2020-11-19T16:28:41.060804+00:00
2020-11-19T16:28:41.060850+00:00
156
false
```\nclass Solution {\n public List<Boolean> prefixesDivBy5(int[] A) {\n int n = 0;\n List<Boolean> answer = new ArrayList<>();\n \n for(int num : A) {\n n += num;\n answer.add(n % 5 == 0);\n n *= 2;\n n = n % 5;\n }\n \n re...
1
0
[]
0
binary-prefix-divisible-by-5
Python, mod
python-mod-by-blue_sky5-030m
\nclass Solution:\n def prefixesDivBy5(self, A: List[int]) -> List[bool]: \n num = 0\n for i in range(len(A)):\n num = 2*num
blue_sky5
NORMAL
2020-11-11T02:55:37.539112+00:00
2020-11-11T02:55:37.539159+00:00
148
false
```\nclass Solution:\n def prefixesDivBy5(self, A: List[int]) -> List[bool]: \n num = 0\n for i in range(len(A)):\n num = 2*num + A[i]\n A[i] = True if num % 5 == 0 else False\n \n return A\n```
1
0
['Python3']
0
binary-prefix-divisible-by-5
Simple & Easy Solution by Python 3
simple-easy-solution-by-python-3-by-jame-jd1p
\nclass Solution:\n def prefixesDivBy5(self, A: List[int]) -> List[bool]:\n for i in range(1, len(A)):\n A[i] += A[i - 1] * 2\n retu
jamesujeon
NORMAL
2020-10-31T14:26:34.813183+00:00
2020-10-31T14:26:34.813208+00:00
134
false
```\nclass Solution:\n def prefixesDivBy5(self, A: List[int]) -> List[bool]:\n for i in range(1, len(A)):\n A[i] += A[i - 1] * 2\n return [n % 5 == 0 for n in A]\n```
1
0
['Python3']
0
binary-prefix-divisible-by-5
Faster then 100% JAVA C++
faster-then-100-java-c-by-akshatkamboj37-yb51
UPVOTE IF YOU LIKE\n\n\nclass Solution {\npublic:\n vector<bool> prefixesDivBy5(vector<int>& A) {\n int n = A.size();\n vector<bool> res(n,fals
Akshatkamboj37
NORMAL
2020-10-12T06:17:09.457765+00:00
2020-10-12T06:17:09.457805+00:00
119
false
# UPVOTE IF YOU LIKE\n```\n\nclass Solution {\npublic:\n vector<bool> prefixesDivBy5(vector<int>& A) {\n int n = A.size();\n vector<bool> res(n,false);\n int val = 0 ;\n for(int i=0;i<n;i++){\n if(!((val = val*2 + A[i])%=5)) \n res[i]=true;\n }\n re...
1
1
[]
0
binary-prefix-divisible-by-5
Python simple solution
python-simple-solution-by-shubham_1611-b234
\nclass Solution:\n def prefixesDivBy5(self, A: List[int]) -> List[bool]:\n n=len(A)\n ans=[]\n sub=""\n \n for i in range
shubham_1611
NORMAL
2020-09-28T00:50:54.269155+00:00
2020-09-28T00:50:54.269184+00:00
139
false
```\nclass Solution:\n def prefixesDivBy5(self, A: List[int]) -> List[bool]:\n n=len(A)\n ans=[]\n sub=""\n \n for i in range(n):\n sub=sub+str(A[i])\n num=int(sub,2)\n \n if num % 5==0:\n ans.append(True)\n else...
1
0
['Python3']
0
minimum-time-to-visit-a-cell-in-a-grid
[C++, Java, Python] 🏓 Ping Pong Dijkstra
c-java-python-ping-pong-dijkstra-by-toju-4yvg
\n# Intuition\nWe want to find minimum time to reach bottom right cell. We\'ll have to traverse the matrix as the time in each cell allows. We can use a priorit
tojuna
NORMAL
2023-02-26T04:01:22.713529+00:00
2023-02-26T05:23:22.040025+00:00
12,367
false
\n# Intuition\nWe want to find minimum time to reach bottom right cell. We\'ll have to traverse the matrix as the time in each cell allows. We can use a priority queue to keep track of time.\nSome things to keep in mind:\n1. If we can not move to the neighboring cells from starting position we can not move anywhere in ...
213
0
['C++', 'Java', 'Python3']
26
minimum-time-to-visit-a-cell-in-a-grid
✅ Video | Beats 100% | Dijkstra's Algorithm
video-beats-100-dijkstras-algorithm-by-p-98q3
\n\nhttps://youtu.be/Kj98r8IgJOQ?si=t5CGvV0eYvsxm6dX\n\n# #1 Mod Dijkstra\'s Algorithm (Beats 95-100%)\npython3 []\nclass Solution:\n def minimumTime(self, g
Piotr_Maminski
NORMAL
2024-11-25T23:51:36.918129+00:00
2024-11-29T03:31:44.379105+00:00
10,347
false
![image.png](https://assets.leetcode.com/users/images/8e17a01f-7982-4fc4-966e-07d3e864c0d6_1732661458.7958922.png)\n\nhttps://youtu.be/Kj98r8IgJOQ?si=t5CGvV0eYvsxm6dX\n\n# #1 Mod Dijkstra\'s Algorithm (Beats 95-100%)\n```python3 []\nclass Solution:\n def minimumTime(self, grid: List[List[int]]) -> int:\n MOVE...
47
3
['C++', 'Java', 'Go', 'TypeScript', 'Python3', 'Rust', 'Ruby', 'JavaScript', 'C#']
5
minimum-time-to-visit-a-cell-in-a-grid
[Python/C++] clean Dijkstra's algorithm solution with explanation
pythonc-clean-dijkstras-algorithm-soluti-dxdg
Explaination\n\nThis problem can be solved using the Dijkstra\'s algorithm with a small variation.\n\nFirstly, note that we can always reach the bottom-right ce
alanlzl
NORMAL
2023-02-26T04:01:00.289722+00:00
2023-02-26T04:23:49.647453+00:00
6,639
false
**Explaination**\n\nThis problem can be solved using the Dijkstra\'s algorithm with a small variation.\n\nFirstly, note that we can always reach the bottom-right cell of the matrix if we can move to at least one adjacent cell (i.e. `grid[0][1]` or `grid[1][0]`). After that, we can simply move back and forth to spend ti...
45
0
['C++', 'Python3']
2
minimum-time-to-visit-a-cell-in-a-grid
Easy Dijkstra | Video solution | Intuition explained
easy-dijkstra-video-solution-intuition-e-c1nd
Intuition\nDoes the solution always exist? \n\n# Approach\nQ. Is there any case where we can not reach the end? \nans: Yes!\n\nQ. That\'s the example test case
i_pranav
NORMAL
2023-02-26T06:25:34.014322+00:00
2023-02-26T07:04:59.309617+00:00
2,477
false
# Intuition\nDoes the solution always exist? \n\n# Approach\nQ. Is there any case where we can not reach the end? \nans: Yes!\n\nQ. That\'s the example test case that has already been provided to us. The exact specifics are that if I can not go to (1,0) and even (0,1) from (0,0) then my answer doesn\'t exist! \nNow in ...
33
0
['C++']
2
minimum-time-to-visit-a-cell-in-a-grid
Dijkstra's Algorithm||87ms Beats 100%
dijkstras-algorithm87ms-beats-100-by-anw-h5yj
Intuition\n Describe your first thoughts on how to solve this problem. \nIt\'s again a question on shortest path.\nSo, Dijkstra\'s Algorithm is applied again.\n
anwendeng
NORMAL
2024-11-29T00:21:35.270519+00:00
2024-12-01T23:37:32.047464+00:00
14,149
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nIt\'s again a question on shortest path.\nSo, Dijkstra\'s Algorithm is applied again.\nThe solution is almost the same in solving [3341. Find Minimum Time to Reach Last Room I](https://leetcode.com/problems/find-minimum-time-to-reach-last...
28
0
['Array', 'Bit Manipulation', 'Breadth-First Search', 'Graph', 'Heap (Priority Queue)', 'Matrix', 'Shortest Path', 'C++', 'Python3']
4
minimum-time-to-visit-a-cell-in-a-grid
Djackstra Solution Visualisation, Commented solution
djackstra-solution-visualisation-comment-veju
\n# Intuition\n Describe your first thoughts on how to solve this problem. \n\nIf you find this useful please give it an upvote!\nSince we have to find the mini
Priyanshu_Chaudhary_
NORMAL
2023-02-26T04:03:55.934788+00:00
2023-02-26T05:34:00.732928+00:00
2,571
false
\n# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n**If you find this useful please give it an upvote!**\nSince we have to find the minimum time and we have to search it. This boils down to **BFS**. However, we have to approach it greedily so we should use **djackstra\'s algorithm whi...
19
0
['Shortest Path', 'C++']
2
minimum-time-to-visit-a-cell-in-a-grid
Java PriorityQueue with Comments
java-priorityqueue-with-comments-by-zade-m1d1
\nclass Solution {\n private static final int[][] DIRS = new int[][] { { 1, 0 }, { -1, 0}, { 0, 1 }, { 0, -1 } };\n public int minimumTime(int[][] grid) {
zadeluca
NORMAL
2023-02-26T04:00:57.675835+00:00
2023-02-26T04:01:42.681008+00:00
1,766
false
```\nclass Solution {\n private static final int[][] DIRS = new int[][] { { 1, 0 }, { -1, 0}, { 0, 1 }, { 0, -1 } };\n public int minimumTime(int[][] grid) {\n if (grid[0][1] > 1 && grid[1][0] > 1) {\n return -1;\n }\n \n int m = grid.length;\n int n = grid[0].length;...
17
0
['Heap (Priority Queue)', 'Java']
2
minimum-time-to-visit-a-cell-in-a-grid
Python | Greedy pattern & Shortest Path (Dijkstra)
python-greedy-pattern-shortest-path-dijk-0oe0
see the Successfully Accepted Submission\n\n# Code\npython3 []\nimport heapq\nfrom typing import List\n\nclass Solution:\n def minimumTime(self, grid: List[L
Khosiyat
NORMAL
2024-11-29T00:51:58.339997+00:00
2024-11-29T00:51:58.340019+00:00
3,085
false
[see the Successfully Accepted Submission](https://leetcode.com/problems/minimum-time-to-visit-a-cell-in-a-grid/submissions/1465412021/?envType=daily-question&envId=2024-11-29)\n\n# Code\n```python3 []\nimport heapq\nfrom typing import List\n\nclass Solution:\n def minimumTime(self, grid: List[List[int]]) -> int:\n ...
16
1
['Python3']
1
minimum-time-to-visit-a-cell-in-a-grid
Back 'n' Forth Dijkstra
back-n-forth-dijkstra-by-votrubac-oeav
Good ol\' Dijkstra once you work out the details.\n\nFirst of all, if the required time for both g[0][1] and g[1][0] is greater than one, we cannot move (return
votrubac
NORMAL
2023-02-26T06:11:53.598361+00:00
2023-02-26T06:52:34.299913+00:00
1,462
false
Good ol\' Dijkstra once you work out the details.\n\nFirst of all, if the required time for both `g[0][1]` and `g[1][0]` is greater than one, we cannot move (return `-1`).\n\nOtherwise, we can always reach the bottom-right cell. If the current time (plus 1) is less than required, we can "wait" till the required time.\n...
13
0
['C']
1
minimum-time-to-visit-a-cell-in-a-grid
Graph + Matrix solution [EXPLAINED]
graph-matrix-solution-explained-by-r9n-79bn
IntuitionFind the shortest time to reach the bottom-right corner of the grid, considering the conditions of when I need to wait based on the values in each cell
r9n
NORMAL
2025-01-06T02:43:06.107763+00:00
2025-01-06T02:43:06.107763+00:00
22
false
# Intuition Find the shortest time to reach the bottom-right corner of the grid, considering the conditions of when I need to wait based on the values in each cell. The challenge is to account for both the time spent moving and waiting, ensuring that I can find the most efficient path. # Approach I’ll use a priority q...
11
0
['Array', 'Breadth-First Search', 'Graph', 'Heap (Priority Queue)', 'Matrix', 'Shortest Path', 'Rust']
0
minimum-time-to-visit-a-cell-in-a-grid
[Python3] Modified Dijkstra. Detailed Solution.
python3-modified-dijkstra-detailed-solut-850m
Intuition\nDijkstra algorithm should always be considered first in shortest time/path questions.\n\n# Approach\nFirst observation:\nIf grid[0][1] <= 1 or grid[1
qinzhe
NORMAL
2023-02-26T04:12:26.227709+00:00
2023-02-26T07:09:51.141706+00:00
1,050
false
# Intuition\nDijkstra algorithm should always be considered first in shortest time/path questions.\n\n# Approach\nFirst observation:\nIf ```grid[0][1] <= 1``` or ```grid[1][0] <= 1```, then you can always reach the bottom right position because you can jump back and forth between the starting point ```(0, 0)``` and its...
10
0
['Python3']
0
minimum-time-to-visit-a-cell-in-a-grid
Dijkstra’s Magic | Find the Fastest Path | C++ | Java | Python | JavaScript 🚀
dijkstras-magic-find-the-fastest-path-c-u13ie
\n# \u2B06\uFE0FUpvote if it helps \u2B06\uFE0F \n\n---\n\n## Connect with me on Linkedin Bijoy Sing.\n\n---\n\n\n###### Solution in C++, Python, Java, and Jav
BijoySingh7
NORMAL
2024-11-29T06:04:24.000827+00:00
2024-11-29T06:04:24.000862+00:00
2,496
false
\n# \u2B06\uFE0FUpvote if it helps \u2B06\uFE0F \n\n---\n\n## Connect with me on Linkedin [Bijoy Sing](https://www.linkedin.com/in/bijoy-sing-236a5a1b2/).\n\n---\n\n\n###### *Solution in C++, Python, Java, and JavaScript*\n\n```cpp []\nclass Solution {\npublic:\n int minimumTime(vector<vector<int>>& grid) {\n ...
9
0
['Breadth-First Search', 'Graph', 'Heap (Priority Queue)', 'Matrix', 'Shortest Path', 'Python', 'C++', 'Java', 'Python3', 'JavaScript']
2
minimum-time-to-visit-a-cell-in-a-grid
C++ || Modified Dijkstra's Algorithm || Explained Approach || Commented code
c-modified-dijkstras-algorithm-explained-84t5
Intuition\n Describe your first thoughts on how to solve this problem. \nSome sort of modified dijkstra\'s algorth will be used.\n# Approach\n Describe your app
batman14
NORMAL
2023-02-26T23:16:48.794749+00:00
2023-02-26T23:16:48.794785+00:00
624
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nSome sort of modified dijkstra\'s algorth will be used.\n# Approach\n<!-- Describe your approach to solving the problem. -->\nMODIFICATION of DIJKSTRA\'S ALGO :-\n\nWe will mainatain a time visited 2d array for keeping the track of minimu...
9
0
['Breadth-First Search', 'Matrix', 'Shortest Path', 'C++']
0
minimum-time-to-visit-a-cell-in-a-grid
[C++] Dijkstra only code
c-dijkstra-only-code-by-dbestvarun-2hl5
{:style="width:440px"}\n\n---\ncpp [easyAF\uD83D\uDE3C.cpp]\nclass Solution {\npublic:\n int minimumTime(vector<vector<int>>& grid) {\n\n int m = grid
dbestvarun
NORMAL
2024-11-29T11:55:31.102023+00:00
2024-11-29T11:55:31.102049+00:00
711
false
![upVote.jpeg](https://assets.leetcode.com/users/images/f9dcf763-6097-45fa-8954-be06596e730a_1732881229.0581257.webp){:style="width:440px"}\n\n---\n```cpp [easyAF\uD83D\uDE3C.cpp]\nclass Solution {\npublic:\n int minimumTime(vector<vector<int>>& grid) {\n\n int m = grid.size(), n = grid[0].size();\n if...
7
0
['Breadth-First Search', 'Heap (Priority Queue)', 'C++']
0
minimum-time-to-visit-a-cell-in-a-grid
Video Explanation (With Intuition)
video-explanation-with-intuition-by-codi-awh1
Explanation\n\nhttps://youtu.be/GAj_Q78lYP4\n\nClick here if the preview above doesn\'t works\n\nNote - Video will be public at 12:15PM IST.\n\n# Code\n\n#defin
codingmohan
NORMAL
2023-02-26T06:19:00.349785+00:00
2023-02-26T06:19:00.349831+00:00
314
false
# Explanation\n\nhttps://youtu.be/GAj_Q78lYP4\n\n[Click here if the preview above doesn\'t works](https://youtu.be/GAj_Q78lYP4)\n\nNote - Video will be public at 12:15PM IST.\n\n# Code\n```\n#define F first\n#define S second\n\nconst vector<vector<int>> neighbours = {\n {0, 1},\n {1, 0},\n {0, -1},\n {-1, 0...
7
0
['C++']
1
minimum-time-to-visit-a-cell-in-a-grid
Python | Dijkstra | Simple Solution
python-dijkstra-simple-solution-by-aryon-kj7g
Code\n\nfrom heapq import heappush, heappop\nclass Solution:\n def minimumTime(self, grid: List[List[int]]) -> int:\n m, n = len(grid), len(grid[0])\n
aryonbe
NORMAL
2023-02-26T04:02:13.414082+00:00
2023-02-26T04:02:13.414125+00:00
523
false
# Code\n```\nfrom heapq import heappush, heappop\nclass Solution:\n def minimumTime(self, grid: List[List[int]]) -> int:\n m, n = len(grid), len(grid[0])\n if grid[0][1] > 1 and grid[1][0] > 1: \n return -1\n heap = [(0,0,0)]\n visited = set()\n while heap:\n ...
7
0
['Python3']
0
minimum-time-to-visit-a-cell-in-a-grid
BFS + PriorityQueue
bfs-priorityqueue-by-svolkovichs-yogd
Intuition\nOn every step we will go to cell we can visit at minimum time.\n\n# Approach\nWe will use BFS + priority queue. Among all possible cells we select on
svolkovichs
NORMAL
2023-02-26T17:43:13.461454+00:00
2023-02-26T17:43:13.461494+00:00
892
false
# Intuition\nOn every step we will go to cell we can visit at minimum time.\n\n# Approach\nWe will use BFS + priority queue. Among all possible cells we select one we can reach at minimum time. How can we calculate minimum time we can reach particular cell. Let consider following example:\n![Screenshot 2023-02-26 at 17...
6
0
['JavaScript']
0
minimum-time-to-visit-a-cell-in-a-grid
pure bfs, no heap, max(grid[i][j])+mn
pure-bfs-no-heap-maxgridijmn-by-jimhorng-6ye9
Approach\n1) as regular BFS, move 1 level at a time and record adjacent cells as new level\n2) the difference is, if adjacent cell\'s required time > current ti
jimhorng
NORMAL
2023-02-26T15:19:21.099142+00:00
2023-03-05T02:09:16.182723+00:00
829
false
# Approach\n1) as regular BFS, move 1 level at a time and record adjacent cells as new level\n2) the difference is, if `adjacent cell\'s required time > current time + 1`, meaning we need to move back-and-forth to reach this cell, so put them in future level to be processed\n3) for 2), one caveat is that when steps bet...
6
0
['Breadth-First Search', 'Python3']
2
minimum-time-to-visit-a-cell-in-a-grid
Not so efficient yet coded by my own dijkstra based solution
not-so-efficient-yet-coded-by-my-own-dij-j2tu
IntuitionThe problem requires finding the minimum time to travel from the top-left corner to the bottom-right corner of a grid while following specific movement
udit_s05
NORMAL
2025-02-03T22:37:47.689304+00:00
2025-02-03T22:37:47.689304+00:00
55
false
# Intuition The problem requires finding the minimum time to travel from the top-left corner to the bottom-right corner of a grid while following specific movement constraints. Since the grid contains values that determine the waiting time at each cell, we need to decide the best route efficiently. This is a shortest-p...
5
0
['Shortest Path', 'C++']
1
minimum-time-to-visit-a-cell-in-a-grid
BFS | Solution for LeetCode#2577
bfs-solution-for-leetcode2577-by-samir02-2jqv
\n\n# Intuition\n Describe your first thoughts on how to solve this problem. \nThe problem requires finding the minimum time to reach the bottom-right cell of a
samir023041
NORMAL
2024-11-29T03:35:30.921876+00:00
2024-11-29T03:35:30.921914+00:00
2,100
false
![image.png](https://assets.leetcode.com/users/images/b53f0a99-e29c-4abb-9716-563c03547c76_1732851323.9855087.png)\n\n# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe problem requires finding the minimum time to reach the bottom-right cell of a grid, where each cell contains a time ...
5
0
['Java']
1
minimum-time-to-visit-a-cell-in-a-grid
Easy C++ Dijkstra with conditions
easy-c-dijkstra-with-conditions-by-maybe-1t62
Intuition\n Describe your first thoughts on how to solve this problem. \nIt seemed like a straightforward shortest path problem with some modification due to th
maybeat12
NORMAL
2023-02-26T04:06:04.815237+00:00
2023-02-26T10:27:05.510584+00:00
1,282
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nIt seemed like a straightforward shortest path problem with some modification due to the given condition: \n\n> You can visit the cell `(row, col)` only when the time you visit it is **greater than or equal** to `grid[row][col]`.\n\n# Ap...
5
0
['Shortest Path', 'C++']
2
minimum-time-to-visit-a-cell-in-a-grid
Easiest Sol Java || Beats 100% ✅ || Simple Dijkstra's Algorithm
easiest-sol-java-beats-100-simple-dijkst-6pc8
Intuition\n Describe your first thoughts on how to solve this problem. \nThe problem involves navigating a grid where each cell has a time constraint representi
user6791FW
NORMAL
2024-11-29T16:08:20.042022+00:00
2024-11-29T16:08:20.042057+00:00
56
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe problem involves navigating a grid where each cell has a **time constraint** representing the earliest time you can enter it. The goal is to find the **minimum time** to reach the bottom-right corner while respecting these constraints...
4
0
['Array', 'Breadth-First Search', 'Graph', 'Heap (Priority Queue)', 'Matrix', 'Shortest Path', 'Java']
0
minimum-time-to-visit-a-cell-in-a-grid
🔥Beats 100 % 🔥 | ✔️ Optimized Dijkstra's Algorithm ✔️ | O(m * nlog(m * n))
beats-100-optimized-dijkstras-algorithm-zkqyv
Intuition\nThis solution uses a priority queue min-heap to efficiently explore the grid in increasing order of time, ensuring the optimal path is chosen to reac
ntrcxst
NORMAL
2024-11-29T03:01:39.825210+00:00
2024-11-29T03:01:39.825239+00:00
303
false
# Intuition\nThis solution uses a **priority queue** `min-heap` to efficiently explore the `grid` in increasing order of time, ensuring the **optimal path** is chosen to reach the target cell at the **bottom-right corner** `rows - 1` `cols - 1`.\n\n# Approach\n`Step 1` **Early Exit Condition**\n- If both possible moves...
4
0
['Array', 'Breadth-First Search', 'Graph', 'Queue', 'Heap (Priority Queue)', 'Matrix', 'Shortest Path', 'Java']
1
minimum-time-to-visit-a-cell-in-a-grid
✅ Dijkstra's Algorithm | Easy to Understand | Detailed Video Explanation 🔥
dijkstras-algorithm-easy-to-understand-d-o6mv
Intuition\nThe problem requires finding the minimum time to traverse from the top-left to the bottom-right of a grid while adhering to specific constraints on c
sahilpcs
NORMAL
2024-11-29T02:52:52.221325+00:00
2024-11-29T02:52:52.221365+00:00
604
false
# Intuition\nThe problem requires finding the minimum time to traverse from the top-left to the bottom-right of a grid while adhering to specific constraints on cell accessibility. Since the grid has a time constraint for visiting each cell, the goal is to explore paths efficiently and prioritize reaching cells sooner....
4
0
['Graph', 'Heap (Priority Queue)', 'Matrix', 'Shortest Path', 'Java']
1
minimum-time-to-visit-a-cell-in-a-grid
[Python3] Simple Dijkstra with modification
python3-simple-dijkstra-with-modificatio-6rea
Intuition\nA small change to Dijkstra\'s algorithm is that we move back and forth until a new cell unlocks after some time. We calculate when the neighbor cell
khadyothan
NORMAL
2024-11-29T01:15:08.425811+00:00
2024-11-29T01:15:08.425850+00:00
218
false
# Intuition\nA small change to Dijkstra\'s algorithm is that we move back and forth until a new cell unlocks after some time. We calculate when the neighbor cell becomes available and push it into the heap with that time.\n\n# Code\n```python3 []\nclass Solution:\n def minimumTime(self, grid: List[List[int]]) -> int...
4
0
['Breadth-First Search', 'Graph', 'Heap (Priority Queue)', 'Shortest Path', 'Python3']
1
minimum-time-to-visit-a-cell-in-a-grid
Modified Dijkstra || Edge Cases || graph || C++
modified-dijkstra-edge-cases-graph-c-by-enc00
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
oreocraz_273
NORMAL
2024-08-02T06:40:54.738546+00:00
2024-08-02T06:40:54.738582+00:00
374
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)$$ --...
4
0
['Graph', 'Ordered Set', 'C++']
1
minimum-time-to-visit-a-cell-in-a-grid
Python || Dijkstra Variant || Explained
python-dijkstra-variant-explained-by-in_-b18i
There is only one case where we can\'t reach last cell , i.e. when all cells adjacent to (0,0) are greater than 1.\nOtherwise we can always keep switching betwe
iN_siDious
NORMAL
2023-04-18T06:04:15.187905+00:00
2023-04-18T06:20:39.180964+00:00
361
false
There is only one case where we can\'t reach last cell , i.e. when all cells adjacent to (0,0) are greater than 1.\nOtherwise we can always keep switching between current cell and the last visited cell to pass the time.\nNow when we are moving from one cell to its adjacent cell -\n1) if the difference between grid valu...
4
0
['Breadth-First Search', 'Heap (Priority Queue)', 'Python', 'Python3']
0
minimum-time-to-visit-a-cell-in-a-grid
[Python] BFS with priority queue; Explained
python-bfs-with-priority-queue-explained-8wcn
The BFS can be used to solve the minimum time or minimum length problem.\n\n(1) In this problem, we must move to a different cell every second. Thus, the only c
wangw1025
NORMAL
2023-02-27T06:36:09.613092+00:00
2023-02-27T06:38:25.005858+00:00
215
false
The BFS can be used to solve the minimum time or minimum length problem.\n\n(1) In this problem, we must move to a different cell every second. Thus, the only case that we cannot reach the bottom right cell is that all the cells next to (0, 0) has required visit time larger than 1. If we have more than 2 visited cells,...
4
0
['Python3']
2
minimum-time-to-visit-a-cell-in-a-grid
Java🍵✅
java-by-mani-26-fd1z
Complexity\n- Time complexity: O(n\xD7m\xD7log(n\xD7m))\n\n- Space complexity: O(n\xD7m)\n\n# Code\njava []\nclass Solution {\n public int minimumTime(int[][
mani-26
NORMAL
2024-11-30T02:10:18.960671+00:00
2024-11-30T02:10:18.960717+00:00
17
false
# Complexity\n- Time complexity: **O(n\xD7m\xD7log(n\xD7m))**\n\n- Space complexity: **O(n\xD7m)**\n\n# Code\n```java []\nclass Solution {\n public int minimumTime(int[][] grid) {\n if (grid[0][1] > 1 && grid[1][0] > 1)\n return -1;\n int n = grid.length;\n int m = grid[0].length;\n ...
3
0
['Breadth-First Search', 'Heap (Priority Queue)', 'Java']
0
minimum-time-to-visit-a-cell-in-a-grid
97% in time, 70 in space using djikistra
97-in-time-70-in-space-using-djikistra-b-cslf
\n\n# Approach\nIf you are able to move once, you can reach any cell because you can just oscillate between 2 cells. If you are at i,j at an odd time let\'s say
yellowfence
NORMAL
2024-11-29T16:44:00.329988+00:00
2024-11-29T16:44:00.330041+00:00
120
false
\n\n# Approach\nIf you are able to move once, you can reach any cell because you can just oscillate between 2 cells. If you are at i,j at an odd time let\'s say 5 and you want to go to i+1, j and grid[i+1][j] = 9 then you can\'t reach grid[i+1][j] at 9 time because oscillation takes 2 seconds. Hence, you will reach gri...
3
0
['C++']
1
minimum-time-to-visit-a-cell-in-a-grid
C# 62ms Runtime Dijkstra with array instead of priority queue
c-62ms-runtime-dijkstra-with-array-inste-lt49
Approach\n\nUsing List<(int, int)>[200_000] in place of PriorityQueue<(int, int, int), int> sped up the Dijkstra implementation x5.\n\nThe constant 200_000 must
ConnectedPuddle
NORMAL
2024-11-29T01:20:13.352103+00:00
2024-11-29T01:20:13.352132+00:00
34
false
# Approach\n\nUsing `List<(int, int)>[200_000]` in place of `PriorityQueue<(int, int, int), int>` sped up the Dijkstra implementation `x5`.\n\nThe constant `200_000` must be greater than `m * n + Max(grid[i][j])`\n\n\n![image.png](https://assets.leetcode.com/users/images/dbb87e58-c791-45e8-a4c5-90b51c3672e3_1732842621....
3
0
['C#']
0
minimum-time-to-visit-a-cell-in-a-grid
Easy C++ Code || Runtime beats - 99.89% , Memory beats - 88.68%
easy-c-code-runtime-beats-9989-memory-be-zn8j
Intuition\n Describe your first thoughts on how to solve this problem. \n\n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Tim
Edwards310
NORMAL
2024-11-29T01:07:23.300338+00:00
2024-11-29T01:09:11.168532+00:00
608
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n![image.png](https://assets.leetcode.com/users/images/0ff4f1e5-1714-438b-9d78-a41242e0f7ba_1732842432.1175325.png)\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your t...
3
2
['Array', 'Breadth-First Search', 'Graph', 'Heap (Priority Queue)', 'Matrix', 'Shortest Path', 'Python', 'C++', 'Java', 'C#']
0
minimum-time-to-visit-a-cell-in-a-grid
C++ solution using priority queue
c-solution-using-priority-queue-by-sachi-gcbm
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
Sachin_Kumar_Sharma
NORMAL
2024-03-29T06:43:21.299915+00:00
2024-03-29T06:43:21.299947+00:00
14
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(M*N)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(M*N)\n<!-- Add your space complexity here, e....
3
0
['C++']
0
minimum-time-to-visit-a-cell-in-a-grid
C++ | Dijkstra + flip-flopping | Simple Logic
c-dijkstra-flip-flopping-simple-logic-by-lrq5
```\nclass Solution {\npublic:\n // To check whether the node is in range or not...\n bool isValid(int row, int col, vector>& grid){\n return row >
SourabCodes
NORMAL
2023-03-01T20:41:25.945277+00:00
2023-03-01T20:41:25.945340+00:00
198
false
```\nclass Solution {\npublic:\n // To check whether the node is in range or not...\n bool isValid(int row, int col, vector<vector<int>>& grid){\n return row >= 0 && col >= 0 && row < grid.size() && col < grid[0].size();\n }\n \n int minimumTime(vector<vector<int>>& grid) {\n \n // m...
3
0
['Math', 'Breadth-First Search', 'Graph']
0
minimum-time-to-visit-a-cell-in-a-grid
[Python3] Dijkstra's algo
python3-dijkstras-algo-by-ye15-ajnw
\n\nclass Solution:\n def minimumTime(self, grid: List[List[int]]) -> int:\n if grid[0][1] <= 1 or grid[1][0] <= 1: \n m, n = len(grid), le
ye15
NORMAL
2023-02-26T04:06:50.748655+00:00
2023-02-26T04:06:50.748687+00:00
432
false
\n```\nclass Solution:\n def minimumTime(self, grid: List[List[int]]) -> int:\n if grid[0][1] <= 1 or grid[1][0] <= 1: \n m, n = len(grid), len(grid[0])\n pq = [(0, 0, 0)]\n dist = defaultdict(lambda : inf, {(0, 0) : 0})\n while pq: \n x, i, j = heapp...
3
0
['Python3']
0
minimum-time-to-visit-a-cell-in-a-grid
✅ [Python & JavaScript] - Easiest Solutions ✅
python-javascript-easiest-solutions-by-d-9ktn
Code\npython3 []\nfrom heapq import heappush, heappop\n\nclass Solution:\n def minimumTime(self, grid: List[List[int]]) -> int:\n m, n = len(grid), le
DanielOL
NORMAL
2024-11-29T18:52:24.287152+00:00
2024-11-29T18:52:24.287192+00:00
43
false
# Code\n```python3 []\nfrom heapq import heappush, heappop\n\nclass Solution:\n def minimumTime(self, grid: List[List[int]]) -> int:\n m, n = len(grid), len(grid[0])\n counter = [[float(\'inf\')] * n for _ in range(m)]\n\n def is_valid(i, j):\n return 0 <= i < m and 0 <= j < n\n\n ...
2
0
['Array', 'Breadth-First Search', 'Graph', 'Heap (Priority Queue)', 'Matrix', 'Shortest Path', 'Python3', 'JavaScript']
2
minimum-time-to-visit-a-cell-in-a-grid
Simple Dijkstra's Algorithm solution with Exp | C++ | Beats 100% | Most optimized
simple-dijkstras-algorithm-solution-with-zx8f
Complexity\n- Time complexity:\nO( M x N log (M x N) )\n- Space complexity:\nO( M x N )\n\n# Code\ncpp []\nclass Solution {\npublic:\n int minimumTime(vector
ujjwal141
NORMAL
2024-11-29T17:29:21.035444+00:00
2024-11-29T17:29:21.035470+00:00
65
false
# Complexity\n- Time complexity:\nO( M x N log (M x N) )\n- Space complexity:\nO( M x N )\n\n# Code\n```cpp []\nclass Solution {\npublic:\n int minimumTime(vector<vector<int>>& grid) {\n\n if(grid[0][1] > 1 && grid[1][0] > 1)\n return -1;\n\n int n = grid.size(), m = grid[0].size();\n\n i...
2
0
['Breadth-First Search', 'Graph', 'Heap (Priority Queue)', 'Matrix', 'Shortest Path', 'C++']
0
minimum-time-to-visit-a-cell-in-a-grid
Easy beat 100% runtime and memory at the same time with C++
easy-beat-100-runtime-and-memory-at-the-25u8b
Intuition\nWe can transfer the question to an easy shortest path problem.\nEasy point minimum time required will be min(adjacent time, grid.time+1/0).\n\n# Appr
william6715
NORMAL
2024-11-29T11:32:17.426339+00:00
2024-11-29T12:37:21.548903+00:00
243
false
# Intuition\nWe can transfer the question to an easy shortest path problem.\nEasy point minimum time required will be **min(adjacent time, grid.time+1/0)**.\n\n# Approach\nEarly return when grid[0][1] and grid[1][0] bigger than 1 at the same time. It is the only situation with no solution.\nFirst, put the top-left cell...
2
0
['C++']
1
minimum-time-to-visit-a-cell-in-a-grid
Beat 95% users || C++ || Easy to understand || Detailed Solution
beat-95-users-c-easy-to-understand-detai-2pzl
Intuition\n Describe your first thoughts on how to solve this problem. \nThe problem involves traversing a grid, starting from the top-left corner to the bottom
Abhishekjha6908
NORMAL
2024-11-29T10:58:36.844276+00:00
2024-11-29T10:58:36.844303+00:00
126
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe problem involves traversing a grid, starting from the top-left corner to the bottom-right corner, with each cell having a time value. The movement from one cell to another can only happen under certain conditions based on the time, an...
2
0
['Breadth-First Search', 'Heap (Priority Queue)', 'Matrix', 'Shortest Path', 'C++']
0
minimum-time-to-visit-a-cell-in-a-grid
Easy to understand || Beat 98%✅
easy-to-understand-beat-98-by-yash9325-mqed
Intuition\nThe problem is about finding the shortest time to reach the bottom-right cell of a grid while respecting the constraints on the earliest time each ce
yash9325
NORMAL
2024-11-29T08:19:43.817393+00:00
2024-11-29T08:19:43.817420+00:00
16
false
# **Intuition**\nThe problem is about finding the shortest time to reach the bottom-right cell of a grid while respecting the constraints on the earliest time each cell can be visited. This can be solved using a **Dijkstra-like approach**, as it involves minimizing a cost (time) to reach the destination.\n\n---\n\n# **...
2
0
['Java']
0
minimum-time-to-visit-a-cell-in-a-grid
Beats 100% ✅|| Waiting Time Approach || Simple Dijkstra's Algorithm || C++ || Java || Python3
beats-100-waiting-time-approach-simple-d-pvtl
Initial Check:\n\n If it\'s impossible to leave the top-left cell because the required time for the first move (grid[0][1] or grid[1][0]) is greater than 1, ret
Sparsh_786
NORMAL
2024-11-29T05:50:27.863594+00:00
2024-11-29T05:51:10.250455+00:00
371
false
**Initial Check:**\n\n* If it\'s impossible to leave the top-left cell because the required time for the first move (grid[0][1] or grid[1][0]) is greater than 1, return -1.\n\n**Priority Queue Setup:**\n\n* Use a priority queue (min-heap) to always explore the next cell with the smallest possible arrival time.\n* Push ...
2
0
['Breadth-First Search', 'Graph', 'C', 'Heap (Priority Queue)', 'Python', 'Java', 'Python3']
2
minimum-time-to-visit-a-cell-in-a-grid
C# Solution for Minimum Time to Visit a Cell In a Grid Problem
c-solution-for-minimum-time-to-visit-a-c-9cem
Intuition\n Describe your first thoughts on how to solve this problem. \nThe problem can be thought of as finding the shortest path in a grid, where each cell h
Aman_Raj_Sinha
NORMAL
2024-11-29T04:17:53.978303+00:00
2024-11-29T04:17:53.978342+00:00
76
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe problem can be thought of as finding the shortest path in a grid, where each cell has a \u201Cgate\u201D that only opens at a specific time (grid[row][col]). You start at the top-left cell at time 0 and must reach the bottom-right cel...
2
0
['C#']
0
minimum-time-to-visit-a-cell-in-a-grid
✅ Simple Java Solution
simple-java-solution-by-harsh__005-52lq
CODE\nJava []\nfinal int[][] dirs = {{-1,0}, {1,0}, {0,-1}, {0,1}};\npublic int minimumTime(int[][] grid) {\n\tint r = grid.length, c = grid[0].length;\n\tif(gr
Harsh__005
NORMAL
2024-11-29T03:26:38.218640+00:00
2024-11-29T03:26:38.218661+00:00
288
false
## **CODE**\n```Java []\nfinal int[][] dirs = {{-1,0}, {1,0}, {0,-1}, {0,1}};\npublic int minimumTime(int[][] grid) {\n\tint r = grid.length, c = grid[0].length;\n\tif(grid[0][1] > 1 && grid[1][0] > 1) return -1;\n\n\tint[][] dp = new int[r][c];\n\tfor(int[] arr: dp) Arrays.fill(arr, -1);\n\tdp[0][0] = 0;\n\n\tQueue<in...
2
0
['Java']
1
minimum-time-to-visit-a-cell-in-a-grid
JS 🎊🎊🎉
js-by-csathnere-wz5z
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
csathnere
NORMAL
2024-11-29T02:43:00.250660+00:00
2024-11-29T02:43:00.250685+00:00
233
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)$$ --...
2
0
['JavaScript']
0
minimum-time-to-visit-a-cell-in-a-grid
100% Beats Baby Solution
100-beats-baby-solution-by-sumeet_sharma-5oze
Intuition\nThe problem involves finding the minimum time required to traverse a grid with specific constraints. The intuition is to treat this as a pathfinding
Sumeet_Sharma-1
NORMAL
2024-11-29T02:26:03.169399+00:00
2024-11-29T02:26:03.169433+00:00
400
false
# Intuition\nThe problem involves finding the minimum time required to traverse a grid with specific constraints. The intuition is to treat this as a pathfinding problem where each cell has a cost, influenced by its value and traversal rules. Using Dijkstra\'s algorithm or a priority queue allows us to efficiently expl...
2
0
['C++']
0
minimum-time-to-visit-a-cell-in-a-grid
Minimum Time to visit a cell in a grid - Easy Explanation -🌟 Beats 100% 🌟
minimum-time-to-visit-a-cell-in-a-grid-e-4bn4
Intuition\n \nPriority Queue can be used with the custom comparator that the first element of the prioirity Queue array that is time is arranged in ascending or
RAJESWARI_P
NORMAL
2024-11-29T01:47:32.404358+00:00
2024-11-29T01:47:32.404381+00:00
106
false
# Intuition\n \nPriority Queue can be used with the custom comparator that the first element of the prioirity Queue array that is time is arranged in ascending order in the priorityQueue.\n\nTo check if the cell is already visited or not, seen boolean array is used for the size of the grid.\n\n<!-- Describe your first ...
2
0
['Array', 'Heap (Priority Queue)', 'Matrix', 'Java']
0
minimum-time-to-visit-a-cell-in-a-grid
Beats 100% ✅✅|Dijkstra's Algorithm|Kotlin
beats-100-dijkstras-algorithmkotlin-by-c-8sl5
Intuition\nIn this problem, we\'re looking for the minimum time to reach the bottom-right cell, where each cell has a minimum time requirement. This creates a w
thearchetypee
NORMAL
2024-11-29T01:14:50.126043+00:00
2024-11-29T02:20:02.329761+00:00
54
false
# Intuition\nIn this problem, we\'re looking for the minimum time to reach the bottom-right cell, where each cell has a minimum time requirement. This creates a weighted graph problem, where the weights are the time we need to wait at each cell.\n\n# Approach\n\nLet\'s break down the solution:\n\n1. Initial Setup:\n ...
2
0
['Heap (Priority Queue)', 'Kotlin']
0
minimum-time-to-visit-a-cell-in-a-grid
Beats 61% Python dijkstra, edge cases explained with examples SUPER CLEAR!
beats-61-python-dijkstra-edge-cases-expl-9vxp
Intuition\n Describe your first thoughts on how to solve this problem. \nDijkstra in 2d matrix with edge cases, do this problem first.\nhttps://leetcode.com/pro
ix221
NORMAL
2024-11-17T03:55:39.814060+00:00
2024-11-17T03:55:39.814086+00:00
153
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nDijkstra in 2d matrix with edge cases, do this problem first.\nhttps://leetcode.com/problems/swim-in-rising-water/\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nThere are 2 cases:\nThe current time allows us to v...
2
0
['Python3']
2
minimum-time-to-visit-a-cell-in-a-grid
12 lines scala bfs recursion
12-lines-scala-bfs-recursion-by-vititov-7oy1
\nobject Solution {\n import collection.immutable.{TreeMap,TreeSet}\n def minimumTime(grid: Array[Array[Int]]): Int = {\n def f(q:Set[(Int,(Int,Int))], v:M
vititov
NORMAL
2024-04-14T18:13:13.976311+00:00
2024-04-14T18:13:13.976344+00:00
13
false
```\nobject Solution {\n import collection.immutable.{TreeMap,TreeSet}\n def minimumTime(grid: Array[Array[Int]]): Int = {\n def f(q:Set[(Int,(Int,Int))], v:Map[(Int,Int),Int]): Int = {\n lazy val ((t0:Int,(x0:Int,y0:Int)),t) = (q.head, q.tail)\n lazy val aa = List((x0-1)->y0, x0->(y0+1), x0->(y0-1), (x0...
2
0
['Scala']
0
minimum-time-to-visit-a-cell-in-a-grid
C++ Modified Dijkstra | Detailed Explanation
c-modified-dijkstra-detailed-explanation-dvgc
Intuition\n Describe your first thoughts on how to solve this problem. \nWe are asked to move in adjacent cell every second.\nBut what if the unvisited cell\'s
YashGadia36
NORMAL
2023-08-18T15:59:14.547514+00:00
2023-08-18T15:59:14.547540+00:00
183
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nWe are asked to move in adjacent cell every second.\nBut what if the unvisited cell\'s time is much more greater than current time passed?\nHere, we will need to iterate on the peviously visited cells so that the time is passed. But doing...
2
0
['Graph', 'Matrix', 'Ordered Set', 'Shortest Path']
0
minimum-time-to-visit-a-cell-in-a-grid
Video Explanation (Hindi) || Dijkstra Algorithm || Edge Case || C++
video-explanation-hindi-dijkstra-algorit-nz6s
Intuition\n Describe your first thoughts on how to solve this problem. \nhttps://youtu.be/lZM00M5oljY\n\n# Approach\n Describe your approach to solving the prob
pkpawan
NORMAL
2023-02-26T11:58:52.488080+00:00
2023-02-26T12:00:01.054950+00:00
621
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nhttps://youtu.be/lZM00M5oljY\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nWe first check cell(0,1) and (1,0) if they both have value>1 we cannot find solution as we will not be able to move forwards.\n\nWe will ...
2
0
['C++']
0
minimum-time-to-visit-a-cell-in-a-grid
Shortest Path - BFS
shortest-path-bfs-by-ajay_jeena_leetcode-iwcf
Approach - We will use a priority queue to store the cells visited and also the minimum time required to get to the cell and mark the cell visited and from each
ajay_jeena_leetcode
NORMAL
2023-02-26T10:39:58.701519+00:00
2023-02-26T11:54:19.673824+00:00
936
false
Approach - We will use a priority queue to store the cells visited and also the minimum time required to get to the cell and mark the cell visited and from each cell we will try to move in all the four directions whenever possible.\nPoints to note - \n\t1- We will use min priority queue with time as the criteria to kee...
2
0
['Breadth-First Search', 'C']
0
minimum-time-to-visit-a-cell-in-a-grid
DFS Approach - Stuck (C++)
dfs-approach-stuck-c-by-jaimit25-i8a6
Not able to clear all test cases, what am i doing wrong?\n\nvector<int> row = {-1, 0, 1, 0};\nvector<int> col = {0, 1, 0, -1};\n\nbool isVisited(int r, int c, v
jaimit25
NORMAL
2023-02-26T04:36:15.228503+00:00
2023-02-26T04:57:07.717880+00:00
1,440
false
Not able to clear all test cases, what am i doing wrong?\n```\nvector<int> row = {-1, 0, 1, 0};\nvector<int> col = {0, 1, 0, -1};\n\nbool isVisited(int r, int c, vector<vector<int>> &visited) {\n if (visited[r][c] == 1)\n return true;\n return false;\n}\nint tm = 0 ;\nvoid help(vector<vector<int>> &grid, int i, in...
2
0
['Depth-First Search', 'Recursion', 'C']
2
minimum-time-to-visit-a-cell-in-a-grid
JAVA solution | PriorityQueue
java-solution-priorityqueue-by-gunner77-ad3s
\n\nclass Solution {\n \n\tpublic int minimumTime(int[][] grid) {\n \n \n int n = grid.length, m = grid[0].length;\n if(grid[0][0
gunner77
NORMAL
2023-02-26T04:08:01.932553+00:00
2023-02-26T04:25:48.142336+00:00
256
false
\n\nclass Solution {\n \n\tpublic int minimumTime(int[][] grid) {\n \n \n int n = grid.length, m = grid[0].length;\n if(grid[0][0] > t) return -1;\n if(grid[0][1] > 1 && grid[1][0] > 1) return -1;\n \n int[][] dir = {{-1,0}, {1,0}, {0,-1}, {0,1}};\n \n P...
2
0
[]
1
minimum-time-to-visit-a-cell-in-a-grid
C++ BFS/PQ Code with explanation
c-bfspq-code-with-explanation-by-jinyeli-suwy
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach : bfs with priority queue\n Describe your approach to solving the problem.
jinyeli1996
NORMAL
2023-02-26T04:02:17.040543+00:00
2023-03-08T05:21:08.534535+00:00
1,375
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach : bfs with priority queue\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: (m*n)log(m*n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npub...
2
0
['C++']
4
minimum-time-to-visit-a-cell-in-a-grid
Dijkstra's
dijkstras-by-akshaypatidar33-1bp2
Code
akshaypatidar33
NORMAL
2025-02-06T09:42:40.235577+00:00
2025-02-06T09:42:40.235577+00:00
14
false
# Code ```cpp [] class Solution { public: int minimumTime(vector<vector<int>>& grid) { if(grid[0][0]>0 || (grid[0][1]>1 && grid[1][0]>1)) return -1; int n = grid.size(), m = grid[0].size(); vector<vector<int>> dist(n,vector<int>(m,INT_MAX)); priority_queue<pair<int, pair<int, int>>,...
1
0
['Breadth-First Search', 'Heap (Priority Queue)', 'Matrix', 'C++']
0
minimum-time-to-visit-a-cell-in-a-grid
Still a variation of Djikstra. The hardness is the identify the wandering?
still-a-variation-of-djikstra-the-hardne-ltup
Intuition\n Describe your first thoughts on how to solve this problem. \nOkay, where did I stuck? I understand the trick of wandering around, but i cannot think
minhtud04
NORMAL
2024-11-30T20:53:31.211411+00:00
2024-11-30T20:53:31.211432+00:00
2
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nOkay, where did I stuck? I understand the trick of wandering around, but i cannot think of using it as the optimal route to reach grid[i][j]. I mean the problem becomes simple when you have the min-Time to reach each grid[i][j] ? The har...
1
0
['Python3']
0
minimum-time-to-visit-a-cell-in-a-grid
Swift💯
swift-by-upvotethispls-qo7n
Modified Dijkstra (accepted answer)\nWe cannot "idle" on a node waiting for access to a neighbor, instead we must hop back and forth with a previous node. This
UpvoteThisPls
NORMAL
2024-11-29T18:41:16.964647+00:00
2024-11-29T21:20:36.733413+00:00
11
false
**Modified Dijkstra (accepted answer)**\nWe cannot "idle" on a node waiting for access to a neighbor, instead we must hop back and forth with a previous node. This is calculated, not simulated, so to do that, we must factor in the parity of the difference of time `t` arriving at node `P` and `t+Q.minT` of node `Q`. Thi...
1
0
['Swift']
0
minimum-time-to-visit-a-cell-in-a-grid
29-11-2024
29-11-2024-by-normalizer-wnm0
\n\n# Code\ncpp []\nusing info = tuple<int, short, short>; // (time, i, j)\nconst static int d[5] = {0, 1, 0, -1, 0};\nclass Solution {\npublic:\n inline sta
Normalizer
NORMAL
2024-11-29T15:17:38.579978+00:00
2024-11-29T15:17:38.580011+00:00
9
false
\n\n# Code\n```cpp []\nusing info = tuple<int, short, short>; // (time, i, j)\nconst static int d[5] = {0, 1, 0, -1, 0};\nclass Solution {\npublic:\n inline static bool isOutside(short i, short j, short n, short m) {\n return i < 0 || i >= n || j < 0 || j >= m;\n }\n\n int minimumTime(vector<vector<int>...
1
0
['C++']
0
minimum-time-to-visit-a-cell-in-a-grid
Swift | Dijkstra
swift-dijkstra-by-pagafan7as-76pu
Code\nswift []\nimport Collections\n\nstruct Node: Comparable {\n var row: Int\n var col: Int\n var time: Int\n\n static func < (lhs: Node, rhs: Nod
pagafan7as
NORMAL
2024-11-29T12:03:18.394201+00:00
2024-11-29T12:05:49.794817+00:00
30
false
# Code\n```swift []\nimport Collections\n\nstruct Node: Comparable {\n var row: Int\n var col: Int\n var time: Int\n\n static func < (lhs: Node, rhs: Node) -> Bool {\n lhs.time < rhs.time\n }\n}\n\nclass Solution {\n func minimumTime(_ grid: [[Int]]) -> Int {\n guard grid[0][1] <= 1 || g...
1
0
['Swift']
0
minimum-time-to-visit-a-cell-in-a-grid
C++ Solution || 95% Beat Time || Shortest path
c-solution-95-beat-time-shortest-path-by-w1bk
Intuition\n Describe your first thoughts on how to solve this problem. \nA Slight variation of shortest path.\n\n# Approach\n Describe your approach to solving
vishalmaurya59
NORMAL
2024-11-29T11:08:55.394690+00:00
2024-11-29T11:08:55.394722+00:00
13
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nA Slight variation of shortest path.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n\n# Complexity\n- Time complexity: $$O(n*mlog(n*m))$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complex...
1
0
['C++']
0
minimum-time-to-visit-a-cell-in-a-grid
This is so stupid its funny
this-is-so-stupid-its-funny-by-3nd3r1-58vv
Code\ngolang []\ntype Item struct {\n\ti int\n j int\n\tpriority int\n\tindex int\n}\n\ntype PriorityQueue []*Item\n\nfunc (pq PriorityQueue) Len() int { ret
3nd3r1
NORMAL
2024-11-29T09:23:29.396469+00:00
2024-11-29T09:23:29.396505+00:00
48
false
# Code\n```golang []\ntype Item struct {\n\ti int\n j int\n\tpriority int\n\tindex int\n}\n\ntype PriorityQueue []*Item\n\nfunc (pq PriorityQueue) Len() int { return len(pq) }\n\nfunc (pq PriorityQueue) Less(i, j int) bool {\n\treturn pq[i].priority < pq[j].priority\n}\n\nfunc (pq PriorityQueue) Swap(i, j int) {\n\t...
1
0
['Go']
0
minimum-time-to-visit-a-cell-in-a-grid
BFS Solution with Great Observations! Easy to Understand!
bfs-solution-with-great-observations-eas-3b1s
Intuition\nThe problem involves finding the minimum time to traverse a grid while respecting cell-specific time constraints. My first thought was to leverage br
rohitaas_beri
NORMAL
2024-11-29T08:27:07.457289+00:00
2024-11-29T08:27:07.457359+00:00
80
false
# Intuition\nThe problem involves finding the minimum time to traverse a grid while respecting cell-specific time constraints. My first thought was to leverage breadth-first search (BFS) for exploring paths in a grid, as it is well-suited for shortest path problems. However, the constraints on traversal time make this ...
1
0
['Binary Search', 'Breadth-First Search', 'C++']
1
minimum-time-to-visit-a-cell-in-a-grid
[C++] || Exact Dijkstra Algo || Priority Queue
c-exact-dijkstra-algo-priority-queue-by-qj8o4
\nclass Solution {\npublic:\n int minimumTime(vector<vector<int>>& grid) \n {\n int n = grid.size(), m = grid[0].size();\n \n if(grid
RIOLOG
NORMAL
2024-11-29T07:01:02.283771+00:00
2024-11-29T07:01:02.283808+00:00
20
false
```\nclass Solution {\npublic:\n int minimumTime(vector<vector<int>>& grid) \n {\n int n = grid.size(), m = grid[0].size();\n \n if(grid[0][1] > grid[0][0] + 1 and grid[1][0] > grid[0][0] + 1) return -1;\n \n priority_queue<pair<int, pair<int, int>>, vector<pair<int, pair<int,...
1
0
['C++']
0
minimum-time-to-visit-a-cell-in-a-grid
[C++] Easy hard
c-easy-hard-by-bora_marian-00ks
Notice that you can move back and forth multiple times to reach a single cell, meaning you can use a previous cell to go back and return to the current cell as
bora_marian
NORMAL
2024-11-29T06:23:47.863843+00:00
2024-11-29T14:23:34.331520+00:00
105
false
Notice that you can move back and forth multiple times to reach a single cell, meaning you can use a previous cell to go back and return to the current cell as many times as necessary to accumulate the required time. The only situation where moving back and forth is not possible is at the very first move, `-1` will be ...
1
0
['C++']
0
minimum-time-to-visit-a-cell-in-a-grid
Easy Solution in C++
easy-solution-in-c-by-dhanu07-tyma
Intuition\n Describe your first thoughts on how to solve this problem. \nTo solve the problem of finding the minimum time to traverse a grid while waiting for c
Dhanu07
NORMAL
2024-11-29T05:51:12.578254+00:00
2024-11-29T05:51:12.578276+00:00
28
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nTo solve the problem of finding the minimum time to traverse a grid while waiting for certain cells to become accessible, we can think of this as a pathfinding problem on a weighted graph. Each cell in the grid can be viewed as a node, an...
1
0
['Array', 'Breadth-First Search', 'Graph', 'Heap (Priority Queue)', 'Matrix', 'Shortest Path', 'C++']
0
minimum-time-to-visit-a-cell-in-a-grid
Simple JAVA Solution | Greedy | Dijkstras Algorithm | Graph
simple-java-solution-greedy-dijkstras-al-6ymt
\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 complexity here, e.g
Sivaganesh-B
NORMAL
2024-11-29T05:29:39.389425+00:00
2024-11-29T05:29:39.389460+00:00
86
false
\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<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```java []\nclass Solution {\n public int minimumTime(int[][] grid) {\n \n if(grid[0][1]>=2 && grid[...
1
0
['Array', 'Breadth-First Search', 'Graph', 'Heap (Priority Queue)', 'Matrix', 'Shortest Path', 'Java']
0
minimum-time-to-visit-a-cell-in-a-grid
Python Dijkstra, Code w/ Notes
python-dijkstra-code-w-notes-by-2pillows-yiq5
Code\npython3 []\nclass Solution:\n def minimumTime(self, grid: List[List[int]]) -> int:\n # if no cells to move at start, then invalid\n if gr
2pillows
NORMAL
2024-11-29T05:25:58.164457+00:00
2024-11-29T05:25:58.164498+00:00
9
false
# Code\n```python3 []\nclass Solution:\n def minimumTime(self, grid: List[List[int]]) -> int:\n # if no cells to move at start, then invalid\n if grid[0][1] > 1 and grid[1][0] > 1:\n return -1\n\n m, n = len(grid), len(grid[0]) # row and cols\n \n directions = [(0, 1), (...
1
0
['Python3']
0
minimum-time-to-visit-a-cell-in-a-grid
JAVA SOLUTION
java-solution-by-ritikk876-np7e
Intuition\n\nThe solution uses a priority queue (min-heap) to handle the time constraints for each cell. Each cell in the grid has a minimum time it becomes acc
Ritikk876
NORMAL
2024-11-29T05:17:56.440508+00:00
2024-11-29T05:17:56.440540+00:00
42
false
# Intuition\n\nThe solution uses a priority queue (min-heap) to handle the time constraints for each cell. Each cell in the grid has a minimum time it becomes accessible, and if you arrive before that time, you must wait. The priority queue ensures that we always process the cell with the least time first, exploring pa...
1
0
['Array', 'Breadth-First Search', 'Heap (Priority Queue)', 'Matrix', 'Java']
0
minimum-time-to-visit-a-cell-in-a-grid
Simple BFS Java Solution
simple-bfs-java-solution-by-aryan0703-9jqv
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
Aryan0703
NORMAL
2024-11-29T04:16:52.078522+00:00
2024-11-29T04:16:52.078559+00:00
75
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)$$ --...
1
0
['Java']
0
minimum-time-to-visit-a-cell-in-a-grid
Java Solution for Minimum Time to Visit a Cell In a Grid Problem
java-solution-for-minimum-time-to-visit-1nbxb
Intuition\n Describe your first thoughts on how to solve this problem. \nThe problem can be visualized as navigating through a grid where each cell represents a
Aman_Raj_Sinha
NORMAL
2024-11-29T04:13:28.985492+00:00
2024-11-29T04:13:28.985521+00:00
43
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe problem can be visualized as navigating through a grid where each cell represents a \u201Cgate\u201D that opens only at or after a specific time (grid[row][col]). The goal is to reach the bottom-right corner (m-1, n-1) from the top-le...
1
0
['Java']
0
minimum-time-to-visit-a-cell-in-a-grid
Rust
rust-by-nuclearoreo-v63q
Code\nrust []\nuse std::collections::{HashSet, BinaryHeap};\nuse std::cmp::Reverse;\n\nimpl Solution {\n pub fn minimum_time(grid: Vec<Vec<i32>>) -> i32 {\n
nuclearoreo
NORMAL
2024-11-29T03:47:11.730243+00:00
2024-11-29T03:47:11.730276+00:00
27
false
# Code\n```rust []\nuse std::collections::{HashSet, BinaryHeap};\nuse std::cmp::Reverse;\n\nimpl Solution {\n pub fn minimum_time(grid: Vec<Vec<i32>>) -> i32 {\n if grid[0][1] > 1 && grid[1][0] > 1 {\n return -1;\n }\n\n let (m, n) = (grid.len(), grid[0].len());\n let mut q = B...
1
0
['Rust']
0
minimum-time-to-visit-a-cell-in-a-grid
[dart] PriorityQueue, Go and Back step solution
dart-priorityqueue-go-and-back-step-solu-lkmh
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
hyungzin
NORMAL
2024-11-29T02:49:31.061558+00:00
2024-11-29T02:49:31.061581+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)$$ --...
1
0
['Dart']
0
minimum-time-to-visit-a-cell-in-a-grid
Java with Dijkstra's Algorithm Approach
java-with-dijkstras-algorithm-approach-b-bjhw
Intuition\nThe problem is essentially about finding the shortest path from the top-left corner to the bottom-right corner of a grid. The challenge lies in the f
ThomasLuuu
NORMAL
2024-11-29T02:20:42.377038+00:00
2024-11-29T02:20:42.377059+00:00
43
false
# Intuition\nThe problem is essentially about finding the shortest path from the top-left corner to the bottom-right corner of a grid. The challenge lies in the fact that the grid values impose constraints on when each cell can be accessed. This hints at a Dijkstra-like approach where we prioritize the earliest possibl...
1
0
['Java']
0
minimum-time-to-visit-a-cell-in-a-grid
[Go] Simple Heap Queue Solution
go-simple-heap-queue-solution-by-hiro111-kigo
Code\ngolang []\nimport (\n "container/heap"\n)\n\nfunc minimumTime(grid [][]int) int {\n // Edge case\n if grid[0][1] > 1 && grid[1][0] > 1 {\n
Hiro111
NORMAL
2024-11-29T02:18:11.351381+00:00
2024-11-29T02:18:11.351410+00:00
8
false
# Code\n```golang []\nimport (\n "container/heap"\n)\n\nfunc minimumTime(grid [][]int) int {\n // Edge case\n if grid[0][1] > 1 && grid[1][0] > 1 {\n return -1\n }\n m, n := len(grid), len(grid[0])\n h := &Heap{[3]int{0, 0, 0}}\n grid[0][0] = -1\n for {\n v := heap.Pop(h).([3]int)\...
1
0
['Go']
1
minimum-time-to-visit-a-cell-in-a-grid
Golang solution with the explanation
golang-solution-with-the-explanation-by-uz438
Intuition\nThe problem requires finding the minimum time to travel from the top-left to the bottom-right of the grid while adhering to the constraints of cell a
alekseiapa
NORMAL
2024-11-29T00:30:49.803121+00:00
2024-11-29T00:30:49.803160+00:00
45
false
# Intuition\nThe problem requires finding the minimum time to travel from the top-left to the bottom-right of the grid while adhering to the constraints of cell availability. A shortest-path algorithm, similar to Dijkstra\'s, is well-suited for this problem because we are minimizing the time to reach each cell.\n\nKey ...
1
0
['Go']
0
minimum-time-to-visit-a-cell-in-a-grid
BFS with Min Heap (Optimized)
bfs-with-min-heap-optimized-by-stalebii-fzpe
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
stalebii
NORMAL
2024-08-23T14:27:43.811318+00:00
2024-08-23T14:27:43.811355+00:00
56
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(m * n * log (m * n))\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(m * n)\n<!-- Add your space c...
1
0
['Array', 'Breadth-First Search', 'Graph', 'Heap (Priority Queue)', 'Matrix', 'Shortest Path', 'Python3']
0
minimum-time-to-visit-a-cell-in-a-grid
Python | Dijkstra’s Algorithm
python-dijkstras-algorithm-by-manojkumar-45t0
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
manojkumar-g
NORMAL
2024-04-23T06:44:36.571993+00:00
2024-04-23T06:44:36.572020+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)$$ --...
1
0
['Python3']
0
minimum-time-to-visit-a-cell-in-a-grid
easy c++ solution
easy-c-solution-by-ar_it_is-hs8g
Intuition\nwe will not reach the destination only when grid[0][1]and grid[1][0] both of them are greater than one otherwise we can go to the grid which is reach
ar_it_is
NORMAL
2023-05-02T07:55:33.682105+00:00
2023-05-02T07:55:33.682154+00:00
188
false
# Intuition\nwe will not reach the destination only when grid[0][1]and grid[1][0] both of them are greater than one otherwise we can go to the grid which is reachable and can increse time by oscillating between the places .For even we will see in howmany minimum time it is possible and we will do the same for odd. \n\n...
1
0
['C++']
0
minimum-time-to-visit-a-cell-in-a-grid
[c++] || Dijkstra || One of the most Understable & Simple solution
c-dijkstra-one-of-the-most-understable-s-4m07
\nclass Solution {\n vector<pair<int,int>> moves={{1,0},{0,1},{-1,0},{0,-1}};\n vector<vector<int>> dp;\n bool check(int x,int y,int n,int m){\n
thinker37
NORMAL
2023-03-11T17:05:47.609541+00:00
2023-03-11T17:05:47.609577+00:00
81
false
```\nclass Solution {\n vector<pair<int,int>> moves={{1,0},{0,1},{-1,0},{0,-1}};\n vector<vector<int>> dp;\n bool check(int x,int y,int n,int m){\n if(x>=0 && x<n && y>=0 && y<m)return true;\n return false;\n }\n \npublic:\n int minimumTime(vector<vector<int>>& grid) {\n int n=grid.siz...
1
0
['Graph']
1
minimum-time-to-visit-a-cell-in-a-grid
Dijkstra | BFS + PriorityQueue
dijkstra-bfs-priorityqueue-by-panevskii-i82p
Code\n\nconst moves = [[0, -1], [0, 1], [1, 0], [-1, 0]]\n\nfunction minimumTime(grid: number[][]): number {\n const N = grid.length;\n const M = grid[0].
panevskii
NORMAL
2023-02-26T18:38:17.447553+00:00
2023-02-26T18:38:39.357270+00:00
68
false
# Code\n```\nconst moves = [[0, -1], [0, 1], [1, 0], [-1, 0]]\n\nfunction minimumTime(grid: number[][]): number {\n const N = grid.length;\n const M = grid[0].length;\n\n const check = (x: number, y: number) => x >= 0 && y >= 0 && x < N && y < M;\n\n let visited: boolean[][] = [...new Array(N)].map(_ => new...
1
0
['TypeScript']
0
minimum-time-to-visit-a-cell-in-a-grid
Graph traversal using a priority queue (Golang)
graph-traversal-using-a-priority-queue-g-mdht
Intuition\nGraph traversal using a priority queue.\n\nIf the time difference with the neighboring cell is even, then we can go back and forth (for example, to t
mastedm
NORMAL
2023-02-26T12:50:03.165930+00:00
2023-02-26T12:50:03.165969+00:00
35
false
# Intuition\nGraph traversal using a priority queue.\n\nIf the time difference with the neighboring cell is even, then we can go back and forth (for example, to the previous cell), thus "wait"\n\n# Code\n```\ntype Cell struct {\n\ttime int\n\trow int\n\tcol int\n}\n\ntype PriorityQueue []*Cell\n\nfunc (pq PriorityQue...
1
0
['Go']
1
minimum-time-to-visit-a-cell-in-a-grid
C++ Clean Code|| Dijkstra’s Algorithm || Self Explanatory
c-clean-code-dijkstras-algorithm-self-ex-2vpx
Intuition\nJust Simple Dijkstra\u2019s implementation we try to go to all nodes possible from current code and if we can\'t reach there at given time than we as
Meet_Sinojia
NORMAL
2023-02-26T11:16:00.364981+00:00
2023-02-26T11:16:00.365014+00:00
1,036
false
# Intuition\nJust Simple Dijkstra\u2019s implementation we try to go to all nodes possible from current code and if we can\'t reach there at given time than we assume that travel back and forth and increase time, and if value of new time for that node is less than the current value in resultant vector than update and a...
1
0
['C++']
1
minimum-time-to-visit-a-cell-in-a-grid
Modified Dijkstra Solution || C++
modified-dijkstra-solution-c-by-shreyd01-whql
We will be using dijkstra algorithm to find minimum time to reach bottom right from top left.\n\n\n\n\n\n\n\ntypedef pair<int,int> pi;\nclass Solution {\npublic
shreyd01
NORMAL
2023-02-26T04:31:44.934105+00:00
2023-02-26T04:31:44.934145+00:00
121
false
We will be using dijkstra algorithm to find minimum time to reach bottom right from top left.\n\n![image](https://assets.leetcode.com/users/images/5dffba17-04e2-4c7f-a2d0-3b5beb3ca38f_1677385772.468185.png)\n![image](https://assets.leetcode.com/users/images/d7d2ae94-ca07-46f0-9e4c-733abfc89b5f_1677385887.5832057.png)\n...
1
0
['Heap (Priority Queue)']
0
minimum-time-to-visit-a-cell-in-a-grid
[Java] Simple Priority Queue | Speed 98.31%
java-simple-priority-queue-speed-9831-by-cxl3
\n\n# Code\n\n public int minimumTime(int[][] grid) {\n if(grid[0][1] > 1 && grid[1][0] > 1) return -1;\n int m = grid.length, n = grid[0].leng
ken0207
NORMAL
2023-02-26T04:01:39.300130+00:00
2023-03-10T02:52:04.192253+00:00
573
false
![image.png](https://assets.leetcode.com/users/images/f388b6ed-e166-430f-a365-d4e8442e5dda_1678416705.2699091.png)\n\n# Code\n```\n public int minimumTime(int[][] grid) {\n if(grid[0][1] > 1 && grid[1][0] > 1) return -1;\n int m = grid.length, n = grid[0].length;\n int[][] directions = new int[]...
1
0
['Java']
2
minimum-time-to-visit-a-cell-in-a-grid
Dijkstra
dijkstra-by-filinovsky-qhdj
IntuitionApproachComplexity Time complexity: Space complexity: Code
Filinovsky
NORMAL
2025-02-25T18:07:59.717026+00:00
2025-02-25T18:07:59.717026+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
['Graph', 'Heap (Priority Queue)', 'Shortest Path', 'Python3']
0
minimum-time-to-visit-a-cell-in-a-grid
dijkstra
dijkstra-by-saikumarkundlapelli-ppjp
IntuitionApproachComplexity Time complexity: Space complexity: Code
saikumarkundlapelli
NORMAL
2025-02-21T18:07:03.114539+00:00
2025-02-21T18:07:03.114539+00:00
6
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
['Heap (Priority Queue)', 'C++']
0