14:14 sorry im very new, we are using while q for the while condition and we are also appending nr and nc in it, wouldnt this mesn that q will never be empty, and the while loop would run inderinitely
Maybe your are not yet prepared for medium questions like this if you are not fully understand the basics. Try some easy questions first can build up the confidence.
Hi, thanks so much for your video on daily leet code problems. I have been working on daily leetcode problems through your videos. I tried to work on this problem earlier. I figured out the logic behind that I need to check water cells, fill in adjacent cells to water cells to 1 and fill out the other cells by increasing 1 to the minimum number of adjacent cells. However, I could not connect this problem with BFS. Also, i understand how BFS algorithm works but I am having issue with applying it to the problems. What are the basic problems that I can practice applying BFS and how do I get better with figuring out algorithm by looking at any problem?
@@JamesBond-mq7pd LeetCode releases the editorial for the daily questions a few days before they are the daily questions, he mentioned this in an old video btw.
I tried to code this in js but gives me time limited exceeded... here's the code, I don't know how to improve it var highestPeak = function(isWater) { let [m, n] = [isWater.length, isWater[0].length] let res = new Array(m).fill(0).map(e=> new Array(n).fill(-1)) let q = [] for(let i=0; i-1 && y>-1 && x
00:34 Add 542. 01 Matrix to the list
No need for a visiting set, right? We can check if the cell is not negative
@@deadlyecho yeah provided that you set them to -1 initially
True tho
Thank u for your efforts neetcode 😀😀
thanks boss, you did it again
14:14 sorry im very new, we are using while q for the while condition and we are also appending nr and nc in it, wouldnt this mesn that q will never be empty, and the while loop would run inderinitely
No, since visited nodes are marked and never added to the queue more than once.
set a breakpoint and run the loop step by step to see how the values are updated :D
You dont always append, so eventually the queue will be empty
Maybe your are not yet prepared for medium questions like this if you are not fully understand the basics. Try some easy questions first can build up the confidence.
Hi, thanks so much for your video on daily leet code problems. I have been working on daily leetcode problems through your videos. I tried to work on this problem earlier. I figured out the logic behind that I need to check water cells, fill in adjacent cells to water cells to 1 and fill out the other cells by increasing 1 to the minimum number of adjacent cells. However, I could not connect this problem with BFS. Also, i understand how BFS algorithm works but I am having issue with applying it to the problems. What are the basic problems that I can practice applying BFS and how do I get better with figuring out algorithm by looking at any problem?
thanks, I was able to do this after seeing the topics and second hint
Thanks!
Thank you
multi source bfs is not that common but i feel like it's a very intruitive/useful algorithm
He predicted this question a couple of days ago!
how?
@@JamesBond-mq7pd Leetcode Daily follows a pattern. The last few questions have been about 2D grids / graphs.
@@yhbarve how he knew that it is gonna be this specific question?
@@JamesBond-mq7pd LeetCode releases the editorial for the daily questions a few days before they are the daily questions, he mentioned this in an old video btw.
he stays grinding
Got a simple bfs for the first time and I don't think it has any optimization
Can't believe I got it by myself .... Thank you so much Neet!
I tried to code this in js but gives me time limited exceeded...
here's the code, I don't know how to improve it
var highestPeak = function(isWater) {
let [m, n] = [isWater.length, isWater[0].length]
let res = new Array(m).fill(0).map(e=> new Array(n).fill(-1))
let q = []
for(let i=0; i-1 && y>-1 && x
the guy that wrote that description should be fired
nah it was alright
@user-my6yf1st8z not for me after seeing neetcode's explaination of the problem description I was able to solve it pretty quickly on my own
I take the first comment today
😆
dayum bro let me hand that nobel prize from my backyard
Bfs sucks for this problem