Very good video. There are a lot of channels that have the same content (leetcode problems), and the difference between them is made by how well the solution is explained. Yours is one of the best I've seen so far, so keep it up.
There's also one another way , by storing the visiting order of the x , y coordinate of the dfs traversal , Let px , py be your starting position of the island Whichever position of that island you visit , just insert that into the vector { x - px , y - py } == > storing the relative position insert this vector into the set
Hi Michael, Nice explanation....just wanted to point out the small difference in implementation and explanation...In base case I guess we should return direction+"0" compared to "0". Even though the code will still work as the representation of water is "0" compared to direction+"0". Thought to point it out for other users. Thanks again for such a beautiful explanation :)
I've been interviewing lately, and I'm not encountering any of these "common questions" I'm seeing on TH-cam. They're all different, and they're all hard. My question today - just the question and the examples of solutions was 63 lines, and I had about 20 minutes to solve it. I am so sick of the IT industry!
Hi Michael, great explanation! Regarding space complexity, wouldn't you have to consider the space for the set? And if so, how would you express that? Thanks!
Thanx , Nice sol! .. Could you also help with Number of Distinct Islands II - LC 711 , i tried sorting the string and then stroing but looks like its not same method .. could you please help
I think time complexity will be m*n*m*n. For the worst case when we have all ones. DFS will visit each element, and make all 1's to 0's but that would not break the for loop, and it will check for all the zero values.
I see what your saying, but I still think it would be O(M*N) because even in the worst case when we have all ones and it has to perform DFS over the entire array, then loop over all the zeros, that means it will touch each position twice. Touching each element twice is not the same thing as O(M^2*N^2), it is O(2*M*N), then drop the constant.
@@AlgosWithMichael Well you were very quick to reply. I was just about to delete the comment. I figured it out, I just took the worst case and did on paper, and yes it will be m*n. Sorry, I don't know what was I imagining while running the algo in my mind.
The string concatenation is a linear time operation that we do at every recursion call right? Why is it not considered for the time complexity analysis?
Very good video. There are a lot of channels that have the same content (leetcode problems), and the difference between them is made by how well the solution is explained. Yours is one of the best I've seen so far, so keep it up.
That's great to hear, thank you for the kind words!
There's also one another way , by storing the visiting order of the x , y coordinate of the dfs traversal ,
Let px , py be your starting position of the island
Whichever position of that island you visit , just insert that into the vector { x - px , y - py } == > storing the relative position
insert this vector into the set
Thanks for the videos. I remembered watching your *Number of islands * video and now I got a job at Amazon as Software engineer. Keep it up!
I'm so glad to hear that! More videos to come
@Sean Novick Definitely. Its important to just get the practice, that way when you see similar problems you know how to solve them.
@Sean Novick did you get the job?
Hi Michael,
Nice explanation....just wanted to point out the small difference in implementation and explanation...In base case I guess we should return direction+"0" compared to "0". Even though the code will still work as the representation of water is "0" compared to direction+"0". Thought to point it out for other users. Thanks again for such a beautiful explanation :)
Yes this is true, even though it might not effect the result, direction + "0" keeps it in sync with other cases.
can i avoid storing out of bounds character 'O' in the string. Why the test case fails in that case. I just want to store 'R' 'L' 'U' and 'D'
Probably the best explanation for this problem
Thank you!!
Very clean code. I am going to follow you from now onwards.
Awesome, thank you!
Love your videos. Always very clear with full explanation. Really appreciate. Please do more!!
Thank you! Will do!
Keep it going michael! very clear, concise and at the same time detailed explanation.
Thank you very much, I definitely will!
Thanks for the great explanation. Can you please explain why it does not work without adding the "O" direction?
i like the way you break down things and explain ... love for the videos from india brother .. keep going
Appreciate the kind words, thanks for watching!
Thanks for this, awesome explanation
You're very welcome!
Thanks for the awesome and crisp explanation man
Happy to help!
Thank you so much for your explanation, I have learned a lot! :)
Very clear explanation! Thanks for the video!!
Anytime!
Awesome. Thanks for the great explanation.
Pretty smart logic for that Set
Haha yeah it's a little tricky. Thanks for watching!
do you really need the U/O/R chars if you just follow the same direction every time?
I've been thinking of the same question. I implemented the same solution without tracking of out/water directions but it didn't seem to be work.
I've been interviewing lately, and I'm not encountering any of these "common questions" I'm seeing on TH-cam. They're all different, and they're all hard. My question today - just the question and the examples of solutions was 63 lines, and I had about 20 minutes to solve it. I am so sick of the IT industry!
thanks for the detailed explanation man.
Great job
Why should we store char for out-of-boundary cells and 0's? Those do not change the island's shape, do they?
thanks for the great explanation
You are welcome!
Hi Michael, great explanation! Regarding space complexity, wouldn't you have to consider the space for the set? And if so, how would you express that? Thanks!
Thanks a lot for the awesome videos. Crisp code and great explanations!
Glad you like them!
Great explanation!
Glad it was helpful!
@@AlgosWithMichael Could you please do a video explaining leetcode problem 146
LRU Cache.
Thanx , Nice sol! .. Could you also help with Number of Distinct Islands II - LC 711 , i tried sorting the string and then stroing but looks like its not same method .. could you please help
Good coding and explanation. Thanks. Btw how did you draw rectangle on screen in the end of video?
Thank you! And I use some editing software
Great video, thank you!
My pleasure!
Great help! Thanks.
Of course, glad you liked it!
Excellent explanation :)
Glad it helped!
Thank you
Challenging but brialliant solution I am not sure how will I get this idea in the interview
Yea, it is very tough
the solution which involves finding the relative coordinates of the island is more intuitive
nice
I think time complexity will be m*n*m*n. For the worst case when we have all ones. DFS will visit each element, and make all 1's to 0's but that would not break the for loop, and it will check for all the zero values.
I see what your saying, but I still think it would be O(M*N) because even in the worst case when we have all ones and it has to perform DFS over the entire array, then loop over all the zeros, that means it will touch each position twice. Touching each element twice is not the same thing as O(M^2*N^2), it is O(2*M*N), then drop the constant.
@@AlgosWithMichael Well you were very quick to reply. I was just about to delete the comment. I figured it out, I just took the worst case and did on paper, and yes it will be m*n. Sorry, I don't know what was I imagining while running the algo in my mind.
No problem, I'm glad you figured it out. I appreciate you watching and commenting!
nice solution!
Thanks!
In just 5 minutes ..an elephant turns into an ant ..THNXX !!!!
Anytime!
The string concatenation is a linear time operation that we do at every recursion call right? Why is it not considered for the time complexity analysis?
I actually didn't think of that. Since the strings are immutable in Java it would make sense that is a linear time operation, but not sure haha
Great explanation! Thanks :)
Thank you so much!
Line 23 should return direction + "O"?
The end solution passed all the test cases on LeetCode!
You explain well.. Why not create list such as for DFS/BFS and put up different questions in it..
I can do that, thanks for the suggestion!
Awesome !
Thank you kind sir!
Great video:) Thanks
Can you please upload the code on github as well?
Thank you so much! The code can be found on the discussion forums on LeetCode.
If you understood the explanation, try writing the code on your own.
Thanks
No problem, glad you liked it!
thanks
No prob!
👏🏿👏🏿👏🏿👏🏿
:D
MLE
Thanks for watching and commenting!