Minimum Time to Visit a Cell In a Grid - Leetcode 2577 - Python

  Рет қаралды 7,202

NeetCodeIO

NeetCodeIO

Күн бұрын

Пікірлер: 32
@vitruvius1202
@vitruvius1202 Күн бұрын
Hey Neetcode, can you please make a video about transitioning from mediums to hard? The biggest focal point in transitioning from easy to mediums was algorithm understanding. But I'm having issues with solving hard problems even though I understand those same algorithms(algorithms: sliding window, dp, etc.) that got me from solving easy to solving mediums. I know you can make an argument that if I can't solve hards, then I clearly don't understand the algorithms I'm working with. But I feel the answer is more nuanced and you'd be able to give valuable insights / strategies.
@satviksrinivas8764
@satviksrinivas8764 Күн бұрын
Hi, I know this question was asked to NeetCode but I just wanted to share that in my experience the key to solving hards is recognizing those little aha moments. In my opinion what makes hard problems hard is that you need to know all the algorithms as you alluded to but each problem has a little aha moment where you need to think outside the box. For example, in this problem the aha moment would be the modular arithmetic part. In other problems it's recognizing that the XOR operator has a certain special property or realizing that you need to use two heaps instead of one, etc... But if you do a lot of these hards and make note of these aha moments I think they start to feel more tangible.
@vitruvius1202
@vitruvius1202 Күн бұрын
@@satviksrinivas8764 Thanks for chiming in. Seems like the actual answer is the most obvious one, which is "Do more hards, and the patterns become more graspable."
@Pippiwazza
@Pippiwazza 17 сағат бұрын
This becomes conceptionally a bit easier to think through, if you preprocess the grid by adding 1 to the cells that can only be reached 1 second after the time value they contain. Then you dont need to bother at all anymore about the parity thing.
@nilfm99
@nilfm99 Күн бұрын
For intuition on the explanation at the end, picture the grid as a chess board alternating white and black squares. It is clear then that each color has a corresponding parity.
@user-my6yf1st8z
@user-my6yf1st8z 16 сағат бұрын
thanks boss, tried to solve this problem implementing the yesterday's solution, but catched WA in tests. Didn't even catch that it's possible to go back and forth.
@fahimimtiaz2153
@fahimimtiaz2153 Күн бұрын
bro is the face of consistency
@omdandade8245
@omdandade8245 19 сағат бұрын
In both yesterday's and today's problem, while implementing the Dijaktras algorithm, you won't update and re-push a node if there exists a shorter way to reach it (you just ingore it 'cause its visited). yesterday I got TLE in Java if I don't do it .
@AnuragKumar-mw6es
@AnuragKumar-mw6es Күн бұрын
You are really awesome. Love your content. Cannot image a world without Neetcode.
@BlunderArmour
@BlunderArmour Күн бұрын
Yeah, no way I was going to come up with that logic of finding the time it takes to visit the next cell. Justified hard.
@b1gfreakn678
@b1gfreakn678 16 сағат бұрын
Off topic to this video, but I’d love to see you solve some Advent of Code puzzles starting in a couple days!
@lian1238
@lian1238 20 сағат бұрын
i wrote 100 lines of code for 2 hours and got a max time exceeded error. thank you neetcode for simultaneously aspiring and making me feel dumb. mostly aspiring :)
@hossammenem7396
@hossammenem7396 Күн бұрын
Thank you Mr. Max Tennyson for this informative video
@MP-ny3ep
@MP-ny3ep Күн бұрын
Very beautifully explained!
@AnivMazumder-c1u
@AnivMazumder-c1u Күн бұрын
Amazing, especially the last insight!!
@floriankubiak7313
@floriankubiak7313 Күн бұрын
I believe this was in a contest this month. I really have to start learning graph algorithms :)
@kane-m9o
@kane-m9o Күн бұрын
and i should too!!
@PurpleDaemon_
@PurpleDaemon_ Күн бұрын
I knew the solution would be related with Greedy, but how do you decide what to pick as the Priority Key (the first element of the heap arrays)? I've tried using is_back_path and is_back_direction, to prefer movement toward the target, but how did you come up to the min_reach_cost solution? Is there a hint, or do you just have to know that such an option exists? BTW not sure if this really helps, but in the final solution I iverted x and y in the heap to again prefer path closer to the target.
@ronbuchanan5432
@ronbuchanan5432 2 сағат бұрын
what if the upper-left cell isn't 0? Let's say it was 100. Is it a valid configuration of the grid?
@Zero-ui4ep
@Zero-ui4ep Күн бұрын
Awesome as always!
@ap2s2000
@ap2s2000 Күн бұрын
Happy Thanksgiving Neet!
@mukherjee.p
@mukherjee.p Күн бұрын
We love some hard problems!
@devmahad
@devmahad 22 сағат бұрын
thanks :)
@kingheisenberg674
@kingheisenberg674 Күн бұрын
is it even possible to solve it within time constraints of an interview or an OA?
@PurpleDaemon_
@PurpleDaemon_ Күн бұрын
In conclusion, this is a regular greedy algorithm that can be written in couple minutes. The whole point is to select the right Priority Key. But unfortunately, I don't see an algorithm to determine it. So IMHO this problem can be solved in minutes (if you know the right PK) or not solved at all.
@EverAfterBreak2
@EverAfterBreak2 Күн бұрын
I highly doubt you will see this in an OA
@g2gsoldchannel
@g2gsoldchannel Күн бұрын
When I see you with the red shirt on the thumbnail, that's when I know I'm cooked for today
@viswes8258
@viswes8258 23 сағат бұрын
I just noticed bro uses green shirt for easy, light green for medium and red for hard with same flowers design! 😭😂
@mrf92
@mrf92 Күн бұрын
why to use viseted with dijkstra? first you say that you are doing a variation of dijkstra and then said it is common to use visited set in BFS.Apparently, these two algorithms are not same. please clarify why do you use visited with dijkstra.
@icvetz
@icvetz Күн бұрын
Is anyone else getting TLE for case 3?
@baophi2322
@baophi2322 Күн бұрын
me
@baophi2322
@baophi2322 Күн бұрын
You might forgot the visit set!
Minimum Obstacle Removal to Reach Corner - Leetcode 2290 - Python
24:52
Is C BETTER than C++ for beginners? // Code Review
31:16
The Cherno
Рет қаралды 63 М.
How To Choose Mac N Cheese Date Night.. 🧀
00:58
Jojo Sim
Рет қаралды 105 МЛН
Microservices Gone Wrong at DoorDash
17:22
NeetCodeIO
Рет қаралды 162 М.
2 Years Of Learning C | Prime Reacts
22:24
ThePrimeTime
Рет қаралды 313 М.
Please Master These 10 Python Functions…
22:17
Tech With Tim
Рет қаралды 220 М.
Dr Gabor Mate answers question about October 7th during conference
12:53
Middle East Eye
Рет қаралды 531 М.
The Best Way to Learn Linux
9:45
Mental Outlaw
Рет қаралды 142 М.
How I Mastered Data Structures and Algorithms in 8 Weeks
15:46
Aman Manazir
Рет қаралды 106 М.
My 10 “Clean” Code Principles (Start These Now)
15:12
Conner Ardman
Рет қаралды 289 М.
СДЕЛАЙ ТАК . Пульт будет работать вечно
9:39
Мужские интересы 79
Рет қаралды 305 М.
Samsung S4 win this 💀 #trollface #troll #trending #trend #viral
0:19
Okotanis Gaming
Рет қаралды 16 МЛН
Which one made you like this video?#keyboard
0:32
Tapkx
Рет қаралды 6 МЛН
Новый матовый iMac M4
0:59
Romancev768
Рет қаралды 1,2 МЛН