Trapping Rain Water || Best optimization || O(N) Time O(1) space || Intuition with Code and Example

Поделиться
HTML-код
  • Опубликовано: 28 сен 2024

Комментарии • 85

  • @jatinbhatoya8420
    @jatinbhatoya8420 2 года назад +64

    oh god, you explained better than striver. hats off. Once you said the word limiting, i understood the whole algo and coded it myself.

    • @piyushsingh9320
      @piyushsingh9320 2 года назад +8

      true,better then big youtube channels

    • @yeswanthh5068
      @yeswanthh5068 2 года назад +4

      Yaa🔥🔥

    • @anandyadav_
      @anandyadav_ Год назад +4

      true!! limiting word helped : )

    • @lostcyrus8578
      @lostcyrus8578 Год назад +4

      i also came after watching striver..you explained better

    • @radhikagokani3660
      @radhikagokani3660 Год назад +1

      Exactly !! Was working on the problem for hours ! LIMITING was the word that made everything clear !!

  • @raufurkhan9191
    @raufurkhan9191 Год назад +3

    Such an easy and lucid explanation. One of best explanation..Kudos..🙂

  • @aishwaryakulkarni9452
    @aishwaryakulkarni9452 Год назад +1

    This was the best explanation so far, concepts are clear! Thanks a bunch🥺 Your channel is so underrated :(

  • @naredlaaalana9371
    @naredlaaalana9371 6 месяцев назад

    Thanks for the detail explanation. Now I got to understand the intuition behind using the two pointer approach to this problem

  • @rohithjakkani8343
    @rohithjakkani8343 Год назад

    Very nice and fast Explaination.Good Concentration till last minute.

  • @infamous_SUSIL
    @infamous_SUSIL 27 дней назад

    Excellent explanation, respect for you ❤❤

  • @sudeepgupta57
    @sudeepgupta57 3 месяца назад

    Thanks for the great explanation

  • @harish5466
    @harish5466 Год назад

    Best and easy explanation have ever seen. Thank you

  • @timacorn2536
    @timacorn2536 Месяц назад

    Hi - thank you for the wonderful explanation!

  • @rudra-18
    @rudra-18 Год назад +1

    Nice explanation with such a clean code!

  • @venkataramanan6354
    @venkataramanan6354 Год назад

    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.🙂

  • @rakshitbro7601
    @rakshitbro7601 3 месяца назад

    you strudied from striver and explained bettter than him
    very well alisha

  • @gitanjalikumari9262
    @gitanjalikumari9262 2 месяца назад

    Thankyou.. great explanation really😊

  • @ayushsinghrathore360
    @ayushsinghrathore360 Год назад +1

    Thanks 👍🙏

  • @KunalSharma-cj5hc
    @KunalSharma-cj5hc 2 года назад

    Very nice explanation literally.
    You just gained one subscriber.

  • @nasirkhansirajbhai8016
    @nasirkhansirajbhai8016 Год назад

    amazing skills.. thank you, could you please post some content on linkedin as well?

  • @bikramshahi8512
    @bikramshahi8512 2 года назад

    great explanation , you deserve more likes and suscribers....

  • @gauravverma2901
    @gauravverma2901 Год назад

    Thank you so much ma'am for such a great Explanation😍

  • @Yash-fh7gm
    @Yash-fh7gm 2 года назад

    thanks for this great video and amazing explanation

  • @ManishKumar-jz2jr
    @ManishKumar-jz2jr Год назад

    Great explanation. Subscribed

  • @ArunsinghParihar-j3j
    @ArunsinghParihar-j3j 4 месяца назад

    Thanks mam

  • @arshdeep011
    @arshdeep011 Год назад

    Best video for this problem!

  • @ashutoshlawaniya9833
    @ashutoshlawaniya9833 2 года назад

    Really, it is awesome 🔥
    Keep it up .

  • @priyankpatel1580
    @priyankpatel1580 Год назад

    Greatest explanation ❤🎉 tnx

  • @kushalshukla444
    @kushalshukla444 Год назад

    nice explanation

  • @Mahmmadhusen072
    @Mahmmadhusen072 2 года назад

    best video thanks. i understood

  • @lakshyakumawat9710
    @lakshyakumawat9710 2 года назад

    Great explanation 🔥

  • @danussh
    @danussh 2 года назад

    Perfect😍

  • @SleepeJobs
    @SleepeJobs 2 года назад

    Thank you ma'am.

  • @prajjwaldubey5787
    @prajjwaldubey5787 10 месяцев назад

    the space complexity is O(n) not O(1) as you mentioned it in thumbnail please change it

  • @AnoopSingh-hx4wm
    @AnoopSingh-hx4wm 2 года назад

    tq mam 🤗

  • @devadityasati7757
    @devadityasati7757 Год назад

    i love your way n u

  • @youtubechannel-ub1xr
    @youtubechannel-ub1xr 5 месяцев назад

    491 likes are too less for your explnation!

  • @SirAkPandey
    @SirAkPandey Год назад +8

    Hats off to your efforts.. You're the most underrated educator on this platform 🙏🙏

  • @RassieVanderDussen-mc8um
    @RassieVanderDussen-mc8um Год назад +6

    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.

  • @hema4266
    @hema4266 9 месяцев назад +2

    You used the right words to build intuition and everything seemed so simple!!!! Thanks a lot

  • @RajeshS-n2j
    @RajeshS-n2j 5 часов назад

    at 19:34, height is 5 not 6, please correct me if I misunderstood. thanks.

  • @somsk56
    @somsk56 17 дней назад

    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

  • @codingvibesofficial
    @codingvibesofficial 26 дней назад

    Great work...everthing runs on brain...and thats why only brains communicate not mouth.

  • @satyajeetkumarjha1482
    @satyajeetkumarjha1482 2 года назад +1

    Actually, ur code could have been more intuitive if u calculated left max and right max and then did leftmax

  • @geld5220
    @geld5220 Месяц назад

    on the first approach with storing the left and right max arrays, is that aslo a term called memoization ?

  • @SelfImprovementtip
    @SelfImprovementtip 4 месяца назад

    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;
    }
    }

  • @abhishekkarn8918
    @abhishekkarn8918 4 месяца назад

    Uncle is extremely cute btw :). Great video though Alisha :)

  • @krishnasahay9694
    @krishnasahay9694 Год назад +5

    Finally got an approach with constant space. Best explanation!!

  • @sharadkumar6658
    @sharadkumar6658 Год назад +2

    Nice mam. It was quite good solution.😇😇

    • @sharadkumar6658
      @sharadkumar6658 Год назад

      Mam plz upload leetcode daily solution too.🙏🙏
      It really help a lot..

  • @sheraurshayri2033
    @sheraurshayri2033 9 месяцев назад

    nice explanation than striver greatttttt

  • @yeswanthh5068
    @yeswanthh5068 2 года назад +1

    Wonderfull explanation,thank u very much 🙂🙂

  • @Alan-bu2hi
    @Alan-bu2hi 2 месяца назад

    Thank you!!!!!

  • @rabindrapatra7151
    @rabindrapatra7151 3 месяца назад

    Beautiful

  • @raedhasan2240
    @raedhasan2240 Год назад

    thank you

  • @ProgBoost
    @ProgBoost Год назад

    Thank a lot ☺

  • @ankit80354
    @ankit80354 Год назад

    thankuu so much dear🥰.

  • @shivanshgupta1509
    @shivanshgupta1509 2 года назад +1

    ThankYou mam!!!

  • @b2aquantschool798
    @b2aquantschool798 6 месяцев назад

    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".

  • @rinkygarg7350
    @rinkygarg7350 6 месяцев назад

    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. 👌👌👏👏

  • @bhargavinaik8145
    @bhargavinaik8145 6 месяцев назад

    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.

  • @kumaravinashsinghabnish4021
    @kumaravinashsinghabnish4021 Год назад

    Really underestimated teacher you are 🎉😮 Awesome 💯 I had watched almost 7 videos of you since morning 🌅 Exclaimed Explained

  • @anonXoXoXo
    @anonXoXoXo 7 месяцев назад

    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 .

  • @addankihasith4672
    @addankihasith4672 9 месяцев назад

    Thanks for the explanation and the efforts you put in making things simpler in this video

  • @techiestart3233
    @techiestart3233 3 года назад

    U are doing great job 🤩thankyou so much for sharing your knowledge.please also make a video on your interview questions

  • @jagan2350
    @jagan2350 Год назад

    your explanation for the problem are greater ,thank you for the video, it was very useful to me

  • @nagendrapp2213
    @nagendrapp2213 3 года назад

    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 ) 😊

  • @charand9597
    @charand9597 Год назад

    very intutive explanation brilliant👑👑👑👑👑👑

  • @expert_solver
    @expert_solver Год назад

    when you said limiting bar decide ans that point, game is over👍

  • @drizzle01
    @drizzle01 Год назад

    20:04 Uncle ji parnam XD,
    great explanation btw!

  • @avijitmaity7436
    @avijitmaity7436 2 года назад

    the explanation is to clean to understand the problem and also simple. thanks

  • @bharathkumar5870
    @bharathkumar5870 3 года назад

    thanks again,learning important problems from ur channel

  • @saveethanotessharingsharee1155

    Can u explain on placement problems of java

  • @ashishtiwari6000
    @ashishtiwari6000 2 года назад

    Must say you are simply awesome !!!!!!

  • @maddycoder1294
    @maddycoder1294 2 года назад

    its very helpful thanku

  • @narendra7556
    @narendra7556 2 года назад

    great Alisha thank you

  • @adityaband6919
    @adityaband6919 Год назад

    amazing explanation

  • @brijrajsinhgohil6576
    @brijrajsinhgohil6576 Год назад

    your intuition is the best!

  • @bishaladhikari9499
    @bishaladhikari9499 Год назад

    Brilliant!

  • @shubhamsukum
    @shubhamsukum 2 года назад

    Thanks!!

  • @vinamrasangal8436
    @vinamrasangal8436 Год назад

    alisha ,u r a gud girl