BFS playlist : kzitem.info/door/PLEI-q7w3s9gRa-dGulP1CZfN-2w_uiGAK Million Dollar advice video : kzitem.info/news/bejne/lmOezGmHfqxmho4
@Ryan-mr9pn
3 жыл бұрын
Yeah this was the error....I was only traversing the cell once...and so 45/47 test cases passed Thanks⚡
@varunrmishra
3 жыл бұрын
Hi, first of all a million thanks for daily videos. These are really informative and helpful. It would be great if you spend a minute on explaining time and space complexity for every question.
@CodeWithSunchitDudeja
3 жыл бұрын
I will keep that in mind.
@tejasnakhate
3 жыл бұрын
Can we drop the visited array and rather just mark visited nodes as -1 in grid itself ?
@kannupriyarana4971
3 жыл бұрын
watched many videos...finally got the point I was missing...please keep making videos with such clear cut explanations. Thankyou :)
@PJ-fl7yk
3 жыл бұрын
Equal Sum Arrays With Minimum Number of Operations ... please EXPlAIN THIS QUESTION SIR
@Sksahu_123
3 жыл бұрын
Please start making editorial of weekly contest
@satyajeetdas6577
Жыл бұрын
This is quite similar how much time required to infect all cells question
@snehalkumar.singh.cse2070
Жыл бұрын
What will be the time complexity of this approach ?
@noobcreations9556
3 жыл бұрын
how do you solve it man! I spent more than 1 hour just understanding the problem.. but didnt even find a way to solve it.. Its more than 2 months im solving problems on daily basis....i can understand the flow after watching any reference but i cant do it on my own... every time i am failing in technical assesments of companies..cant even solve 1 problem which seems very basic.....when i refer online for the same problem i can understand it in a minute, but thats no use....... Without watching any reference/hints im unable to solve any kind problem on my own... this is literally more than frustation level.. 😥
@MGtvMusic
3 жыл бұрын
Keep working hard and understand the concepts and study them thoroughly and be consistent and eventually you'll be able to come up with solutions by your own. Consistency is key. Keep solving again and again Trust me you can do it You will eventually figure out the logic by yourself. 2 months is not a lot of time,Technically you're just a beginner Do not lose your motivation Keep working every single day
@Thepankaz1
3 жыл бұрын
Dont directly jump in hard problems.
@santoshvarma996
3 жыл бұрын
I was in the same boat 6 months back. one thing that helped was try to solve the problem mentally, as if you are solving it on paper. after that try coding the same thought process.
@CodeWithSunchitDudeja
3 жыл бұрын
Dont loose hope, It took years of practise before I could solve it myself, so you still have time
@thedataguyfromB
3 жыл бұрын
One thing u could do , try to solve easy and medium level questions and then after 10 or 15 days try to solve it again without any reference . this will definitely boost your confidence when u will be able to solve already solved questions without any ref. and eventually this will start happening with the new questions as well . keep learning ;) don't worry at initial stage every one is there in same hoodie.
@vahidsaber2582
2 жыл бұрын
Have a question please: Why are there two while loops? In another words, why return level and not the number of steps(pushes to queue). I did try to remove the inner while loop and the returned number obviously shooted up.
@abhishekahlawat6729
3 жыл бұрын
isn't adding the new obstacle entry once to the queue sufficient, even adding two entries wouldn't we be processing same data twice?
@daanishsarguru3044
3 жыл бұрын
yes, that'd work
@Coolharshit149
3 жыл бұрын
Yes you are right it should actually be obstacle[x][y] rather than oldObstacle in 2nd cond and it is also passing all the cases
@harshavardhanm7091
3 жыл бұрын
@@Coolharshit149 I replaced oldObstacleCount with obstacle[x][y] in the 2nd condition and commented out the line where it adds to the queue but didn't pass all the test cases.. Am I missing anything? Appreciate your help!
@Coolharshit149
2 жыл бұрын
@@harshavardhanm7091 I am talking about these conditions int curk = oldK + grid[r][c]; if(!visited[r][c] && curk
@shyamsundar214
3 жыл бұрын
Description is different
@CodeWithSunchitDudeja
3 жыл бұрын
Fixed, thanks copy paste error.
@Coolharshit149
3 жыл бұрын
Awesome Explanation. I cannot clear this doubt why DFS won't work in this case?
@mazecore
2 жыл бұрын
cause DFS goes deep (to the end) into every direction before it finds it's not the shortest one, thus wasting time. BFS goes step by step in every direction and guarantees to find the shortest route before going too far in the wrong directions.
@mrrishiraj88
3 жыл бұрын
👍
@MGtvMusic
3 жыл бұрын
What if we find out that a better path to an older co-ordinate is obtained later but they are not immediate neighbours? Wouldn't we perform a cascade of some sort or reiterate to ensure that?
@dravitlochangupta9658
3 жыл бұрын
Had the same doubt, but as I read through your comment, I realised chance of that happening is low. BFS ensures the shortest path is evaluated first.
@MGtvMusic
3 жыл бұрын
@@dravitlochangupta9658 yes I understood it myself Also the fact that we are going to evaluate the shortest path for the last coordinate so there's no chance of that happening or affecting our result in anyway
@coder1015
3 жыл бұрын
Amazing
@CodeWithSunchitDudeja
3 жыл бұрын
Thank you! Cheers!
@Thepankaz1
3 жыл бұрын
Suppose we reach a cell where one path has distance 3 and lives 0 , other path has distance 5 and lives 3 . You will update the path with later but what if 1st path reach the end with shorted path?
@MGtvMusic
3 жыл бұрын
BFS would give you that path as well Notice that the direction goes all sides
@MGtvMusic
3 жыл бұрын
Keep in mind that ultimately you don't need the shortest/least obstacle path to a previously visited coordinate but only to the bottom-right One I hope that clears your confusion
@joudsultan8098
2 жыл бұрын
@@MGtvMusic can you please explain more🥲?
@LegitGamer2345
3 жыл бұрын
waiting for todays video , its a hard hard question
@vikramkirubaharan7737
3 жыл бұрын
Can you please share your leetcode profile link here.
Пікірлер: 44