Nice explaination, Can you please create a video for time management, like the sleep crisis during preparation, It feels like a sleep deprivation is on the way, please help tackling.🙂
It never happened that I came to understand the solution from your video and not understand it. Your intution and approach are so easy to understand. Thanks and please continue this great work.
class Solution { public int trap(int[] height) { if (height == null || height.length == 0) { return 0; } int left = 0; // Initialize left pointer int right = height.length - 1; // Initialize right pointer int leftMax = height[left]; // Maximum height to the left int rightMax = height[right]; // Maximum height to the right int ans = 0; // Variable to store the total water trapped while (left < right) { if (leftMax < rightMax) { // If leftMax is less than rightMax, process the left side left++; leftMax = Math.max(leftMax, height[left]); ans += Math.max(0, leftMax - height[left]); } else { // If rightMax is less than or equal to leftMax, process the right side right--; rightMax = Math.max(rightMax, height[right]); ans += Math.max(0, rightMax - height[right]); } } return ans; } }
Even this video is two year old and I am watching it right now, after watching multiple other video solutions ,I can confidently say that your explanation is the best out of all I have watched till now. This video is ever green. Thanks for your effort. Please Don't quit from making this type of video, keep it up at least for your viewers. The only word I can say about this video is "Excellent".
though I saw this approach many times but couldn't understand before so keep looking for more. Only, in this video, I could actually feel that I understood the concept. Thanks and keep it up. 👌👌👏👏
Thank you so much for this explanation, I had solved it with 2 arrays, was struggling alot to understand the O(1) space logic. The words you used really helped to unlock that link.
oh my god,such a nice explanation . its not just this question ,when no one is able to make me understand the solution ,its always your solution which help me understand .
nice explanation and if you don't mind could you please reduce the screen size (zoom out ) for all your videos so I can able to see whole code (screen) and also please make a video on how to maintain the consistency (problem solving ) 😊
oh god, you explained better than striver. hats off. Once you said the word limiting, i understood the whole algo and coded it myself.
true,better then big youtube channels
Yaa🔥🔥
true!! limiting word helped : )
i also came after watching striver..you explained better
Exactly !! Was working on the problem for hours ! LIMITING was the word that made everything clear !!
Such an easy and lucid explanation. One of best explanation..Kudos..🙂
This was the best explanation so far, concepts are clear! Thanks a bunch🥺 Your channel is so underrated :(
Thanks for the detail explanation. Now I got to understand the intuition behind using the two pointer approach to this problem
Very nice and fast Explaination.Good Concentration till last minute.
Excellent explanation, respect for you ❤❤
Thanks for the great explanation
Best and easy explanation have ever seen. Thank you
Hi - thank you for the wonderful explanation!
Nice explanation with such a clean code!
Nice explaination, Can you please create a video for time management, like the sleep crisis during preparation, It feels like a sleep deprivation is on the way, please help tackling.🙂
you strudied from striver and explained bettter than him
very well alisha
Thankyou.. great explanation really😊
Thanks 👍🙏
Very nice explanation literally.
You just gained one subscriber.
amazing skills.. thank you, could you please post some content on linkedin as well?
great explanation , you deserve more likes and suscribers....
Thank you so much ma'am for such a great Explanation😍
thanks for this great video and amazing explanation
Great explanation. Subscribed
Thanks mam
Best video for this problem!
Really, it is awesome 🔥
Keep it up .
Greatest explanation ❤🎉 tnx
nice explanation
best video thanks. i understood
Great explanation 🔥
Perfect😍
Thank you ma'am.
the space complexity is O(n) not O(1) as you mentioned it in thumbnail please change it
we are not using any array or stack so how the sc is o(n)
think again
tq mam 🤗
i love your way n u
491 likes are too less for your explnation!
Hats off to your efforts.. You're the most underrated educator on this platform 🙏🙏
It never happened that I came to understand the solution from your video and not understand it. Your intution and approach are so easy to understand. Thanks and please continue this great work.
You used the right words to build intuition and everything seemed so simple!!!! Thanks a lot
at 19:34, height is 5 not 6, please correct me if I misunderstood. thanks.
I have been trying to understand this approach from Striver for 2 days but didnt But now after watching your video its clean and clear
Great work...everthing runs on brain...and thats why only brains communicate not mouth.
Actually, ur code could have been more intuitive if u calculated left max and right max and then did leftmax
on the first approach with storing the left and right max arrays, is that aslo a term called memoization ?
class Solution {
public int trap(int[] height) {
if (height == null || height.length == 0) {
return 0;
}
int left = 0; // Initialize left pointer
int right = height.length - 1; // Initialize right pointer
int leftMax = height[left]; // Maximum height to the left
int rightMax = height[right]; // Maximum height to the right
int ans = 0; // Variable to store the total water trapped
while (left < right) {
if (leftMax < rightMax) {
// If leftMax is less than rightMax, process the left side
left++;
leftMax = Math.max(leftMax, height[left]);
ans += Math.max(0, leftMax - height[left]);
} else {
// If rightMax is less than or equal to leftMax, process the right side
right--;
rightMax = Math.max(rightMax, height[right]);
ans += Math.max(0, rightMax - height[right]);
}
}
return ans;
}
}
Uncle is extremely cute btw :). Great video though Alisha :)
Finally got an approach with constant space. Best explanation!!
Nice mam. It was quite good solution.😇😇
Mam plz upload leetcode daily solution too.🙏🙏
It really help a lot..
nice explanation than striver greatttttt
Wonderfull explanation,thank u very much 🙂🙂
Thank you!!!!!
Beautiful
thank you
Thank a lot ☺
thankuu so much dear🥰.
ThankYou mam!!!
Even this video is two year old and I am watching it right now, after watching multiple other video solutions ,I can confidently say that your explanation is the best out of all I have watched till now. This video is ever green. Thanks for your effort. Please Don't quit from making this type of video, keep it up at least for your viewers. The only word I can say about this video is "Excellent".
though I saw this approach many times but couldn't understand before so keep looking for more. Only, in this video, I could actually feel that I understood the concept. Thanks and keep it up. 👌👌👏👏
Thank you so much for this explanation, I had solved it with 2 arrays, was struggling alot to understand the O(1) space logic. The words you used really helped to unlock that link.
Really underestimated teacher you are 🎉😮 Awesome 💯 I had watched almost 7 videos of you since morning 🌅 Exclaimed Explained
oh my god,such a nice explanation .
its not just this question ,when no one is able to make me understand the solution ,its always your solution which help me understand .
Thanks for the explanation and the efforts you put in making things simpler in this video
U are doing great job 🤩thankyou so much for sharing your knowledge.please also make a video on your interview questions
your explanation for the problem are greater ,thank you for the video, it was very useful to me
nice explanation and if you don't mind could you please reduce the screen size (zoom out ) for all your videos so I can able to see whole code (screen)
and also please make a video on how to maintain the consistency (problem solving ) 😊
very intutive explanation brilliant👑👑👑👑👑👑
when you said limiting bar decide ans that point, game is over👍
20:04 Uncle ji parnam XD,
great explanation btw!
the explanation is to clean to understand the problem and also simple. thanks
thanks again,learning important problems from ur channel
Can u explain on placement problems of java
Must say you are simply awesome !!!!!!
its very helpful thanku
great Alisha thank you
amazing explanation
your intuition is the best!
Brilliant!
Thanks!!
alisha ,u r a gud girl