great video sir, i had come to understand the O(1) space solution, and your explanation is shorter and much much crisper than anyone else's. keep up the great work.
Generally dont prefer commenting unless really impressed. This was a great solution and I could code very easily myself. thanks for all the effort spent.
Best video on internet for Trapping Rain water.. I wouldn't have understood this problem if I hadn't found this video... Kudos for the great explanation....
I watched many videos to understand the concept of two pointer approach.. But after watching this video, It became so clear to me.... Next time if I am unable to solve any question I will come to this channel first... This is a very underrated channel..
In every Questions , too much concept as well as hidden cases . When i want to try same questions after 4 days or a week i got stuck but your explanation make question easier for me. ::))
I've watched many of your videos. Your explanations are always very easy to understand. Thank you for creating these videos; you are doing so much good.
Right at 21:35 I stopped and boom my code got accepted, thanks a lot bhai, I was trying to solve with 2 pointer approach as well but couldn't deal with the water-level stuff, which you made so easy to understand and grasp, and not just that also for improvising code in such an awesome way with 2N Auxiliary space. Again thanks a lot bhai
I had seen your video of solving the area of histogram ..so first thing came in my mind to take 2 stacks to get left and right max ...while writing the code I realized that I can solve this without stack .... after that I saw your complete video and got o(1) space method ... this is crazy
Thank you for this video! I appreciate you drawing out the base cases and explaining everything in detail. This is definitely the most helpful video for this problem :)
It's sad TH-cam has hidden dislikes on a video, stops good videos like this from showing up first. Thanks. 38k views and 1.2k likes? c'mon guys hit the like button.
Your explanation fits the process of how to solve a problem -- from observation of cases to generalization to optimization to final code. Pure memorization of the solution without following this process is not helpful to interviews
As we go from left to right `max_left` could only increase (or stay the same). As we go from right to left `max_right` could only increase (or stay the same). That is why when we move pointers L and R, `max_left` and `max_right` compete with each other. First one gets larger, then the other gets larger, then the other gets larger. And we swing from one side to the other side moving pointer L and R closer to each other.
I did not understand one thing @TechDose . Can you please tell me why are we choosing to go towards LEFT when left height is less and why to right-- when RIGHT height is less ?
Thanks for such an excellent explanation. I had one query, I think the code won't give the right sum for the array {4,3,1,5,0,5,0,3}. Can you help here?
@ techdose bro fantastic explanation Just a follow up question If the bars are of variable width then can I use an array of structures to store the length and width of each bar and calculate the amount of water trapped or is there any other approach?
Width doesn't affect the max heights on left and right. Instead of just taking ht, just multiply ht by current bar width. That's it. Same code will run
very nice explanation thank you 💞, How do we develop this intuition sir ? , i mean the logic at the end was a bit tricky how can one spontaneously come up with such solution??
This is one of the best explanations I've seen so far on the internet.
Thanks :)
Your patience while explaining is quite appreciable
Thanks :)
This might be the longest video on your channel. Very well covered. Thank you :)
Welcome
i did not even notice. Time flies.
@@abhilashpatel3036 Absolutely, Time flies, but leaves its shadow behind.
Hands down the best explanation on youtube... Better than top creators.
After finding ur videos, i never watch any other channel.... i super like how u explain stuff, and different improved ways to solve it. thank you man!
Welcome :)
Dang man, you made a Leetcode Hard problem seem like an Easy. Subscribed :)
👍🏼
Hehehe, I was thinking the same thing. Some people are natural teachers.
Man, you just made a hard leetcode problem so easy that I just coded it all by myself successfully.
Can't thank you enough
great :)
great video sir, i had come to understand the O(1) space solution, and your explanation is shorter and much much crisper than anyone else's. keep up the great work.
Generally dont prefer commenting unless really impressed. This was a great solution and I could code very easily myself. thanks for all the effort spent.
Welcome :)
It's rare to have a video with zero downvotes! great explanation.
Thanks
The solution of this problem is very simple but the way sir tells how to approach a problem is amazing .
:)
Best video on internet for Trapping Rain water.. I wouldn't have understood this problem if I hadn't found this video... Kudos for the great explanation....
Your explanation resolved all my doubts and i was able to write code by myself after watching your video for 10 minutes.
Thank you
Thanks 😊
This is hands down the best explanation I have seen for this question. I am surprised it doesn't have many views!
Thanks
I watched many videos to understand the concept of two pointer approach.. But after watching this video, It became so clear to me.... Next time if I am unable to solve any question I will come to this channel first... This is a very underrated channel..
Thanks :)
In every Questions , too much concept as well as hidden cases . When i want to try same questions after 4 days or a week i got stuck but your explanation make question easier for me. ::))
Great :)
Your channel is really great! You should definitely have more subscriber than most of other creators who create useless roadmaps.
Happy Teacher's day. Really appreciate you as a teacher.
TC =O(n)
SC =O(1)
=> 24:25
superb explaination
Thanks 😊
Hands down the best explanation of this problem on the internet. 🙏🙏
You Deserve more than a million subscribers for such a great content!
Thanks :)
No one explains like this.
Loved your videos
Thanks 😊
I've watched many of your videos. Your explanations are always very easy to understand. Thank you for creating these videos; you are doing so much good.
thanks :)
Right at 21:35 I stopped and boom my code got accepted, thanks a lot bhai, I was trying to solve with 2 pointer approach as well but couldn't deal with the water-level stuff, which you made so easy to understand and grasp, and not just that also for improvising code in such an awesome way with 2N Auxiliary space. Again thanks a lot bhai
Nobody cares thou...keep coding
I had seen your video of solving the area of histogram ..so first thing came in my mind to take 2 stacks to get left and right max ...while writing the code I realized that I can solve this without stack .... after that I saw your complete video and got o(1) space method ... this is crazy
😂 hahaha. Very nice to see you apply the concepts of my previous video :) But there is always someone better than you 😉
@@techdose4u =D =D
You sir, did an awesome job breaking this down and making it simpler to understand. Thank you for your efforts. Appreciate it
Nicely explained step by step, appreciated it, understood the approach in one go...you deserve more subs & views...hope you will reach there ..:)
Thanks ❤️
Awesome explanation, covering all cases with detail and clarity!
Thanks 😊
One of the best explanations! Thanks a lot!
Welcome :)
I bet this vdo has got the best explanation for the two pointer approach...thanks a ton TechDose😊
Welcome 😄
giving all three possible solutions u make life easy. Thanks a lot
Best explanation ever with best level of calmness and patience 😊😊
brooooooooooooooooo best explaination ever
Thanks :)
Awesome Explanation, better from other TH-camrs
Thanks 😊
Most underrated channel
Awesome explanation . Even kids can understand after watching this video. Thank you very much
Welcome 😁
Techdose to me is a game changer
Excellent explanation!
Your channel will definitely grow a lot
Thanks 😊
Thanks for this beautiful video, your explanation made me code myself... At the end of 16 min of the video, I understood and coded in python.
Ur patience is appreciable
Thanks :)
So far the best explaination. Thank you so much sir.
Thank you for this video! I appreciate you drawing out the base cases and explaining everything in detail. This is definitely the most helpful video for this problem :)
You are the best. I am now sharing with my friends!!
The best explanation for the problems, Ty sir for ur patience and amazing explanations
Thanks alot! I was struggling to understand the logiv but now its clear
Great
sir you explained very nicely step by step 👌👌👌
thank you for your explain , from simple solution to better solution !
Welcome 😊
awesome explanation, the way you explained corner cases are great. keep it up
Welcome :)
An incredibly detailed and amazing presentation. Thank you!
Very well explained sir , your explanation for this question is crystal clear. I really liked this problem it was very intuitive
Thanks :)
Thanks a ton for explaining solution in detail. It's really a tough job. Keep it up!!!
Very underrated 👍🏼
:)
Champ tech dose🙏 👏
Well done
When the content is so good, subscribing and liking are on autopilot.
You are very easy and nice to understand.
Thanks ☺️
Index starts from 1 to arr.len-1
Totalwater+=Math.min(leftmax of current index element, rightmax of current index element)-current index element
Nice 1 liner :)
what a coincidence that we both were working on the same problem.
:O
Best solution explaination to this problem. 🙌
Thanks :)
Great video sir!! What an explanation! Keep uploading such videos 🙏🙏
Welcome :)
loved that o(1) space method
thankyou so much for this video! you just made this hard task quite easy.
thank you for this, this is extremely well explained
Thanks
Great explanation sir..hope expecting more videos from tech dose..
Sure. I will keep uploading :)
It's sad TH-cam has hidden dislikes on a video, stops good videos like this from showing up first. Thanks. 38k views and 1.2k likes? c'mon guys hit the like button.
Thanks 😊
amazing crystal clear
explaination
Thanks
The last solution where time-O(N) and space-O(1) method is amazing. Came here after many leetcode solutions!
Very nice explanation 👌thank youu
Welcome 😀
Thank you so much you explained these questions by previously known methods because others are making it very complicated for reducing code size()
Welcome :)
Great work
Keep going 👍
Your explanation fits the process of how to solve a problem -- from observation of cases to generalization to optimization to final code. Pure memorization of the solution without following this process is not helpful to interviews
Best explanation 👏
Thanks ☺️
Just explained it calmly loved that.🤗
Thanks
Nice explanation sir......you are doing a great job
Thanks :)
I think in the last condition it will be (l
As we go from left to right `max_left` could only increase (or stay the same).
As we go from right to left `max_right` could only increase (or stay the same).
That is why when we move pointers L and R, `max_left` and `max_right` compete with each other. First one gets larger, then the other gets larger, then the other gets larger. And we swing from one side to the other side moving pointer L and R closer to each other.
Excellent explaining.
Very good explanation
Very nice explanation🎉
thanks
I did not understand one thing @TechDose . Can you please tell me why are we choosing to go towards LEFT when left height is less and why to right-- when RIGHT height is less ?
Best Explanation.
Thanks
Thanks for the video. Can u logically explain how u chose 2 pointers approach?
Very good solution!,
Thanks 😊
Clear explanation!! Thanks bro
Excellent Explanation
No doubt why this video has no dislikes.
🤗
Thanks for such an excellent explanation. I had one query, I think the code won't give the right sum for the array {4,3,1,5,0,5,0,3}. Can you help here?
@TECH DOSE 1st approach is brute force approach right
Simply Amazing!!
Thanks ☺️
Nice Explanation! Thanks!
excellent explanation. awesome solution.
amazing explanation bro!
very clear explanation!
Great explanation, thank you.
@ techdose bro fantastic explanation
Just a follow up question
If the bars are of variable width then can I use an array of structures to store the length and width of each bar and calculate the amount of water trapped or is there any other approach?
Width doesn't affect the max heights on left and right. Instead of just taking ht, just multiply ht by current bar width. That's it. Same code will run
This was an excellent explanation.
Great explanation!
very nice explanation thank you 💞, How do we develop this intuition sir ? , i mean the logic at the end was a bit tricky how can one spontaneously come up with such solution??
Thank you so much for doing this on my request.... best bro...
Welcome :)
you made it easy. Thank you.
This saved my day :-) Thank you very much
:)