Trapping Rainwater Problem | Leetcode #42

SdĂ­let
VloĆŸit
  • čas pƙidĂĄn 24. 03. 2021
  • This video explains a very important programming interview problem which is the trapping rainwater problem.In this problem, given an array representing elevation map, we are required to find the amount of water the elevation map can trap.I have explained all the approaches for solving this problem starting from the bruteforce approach to the most optimal approach.I have shown how we can process and highly optimize the time complexity.
    CODE LINK is present below as usual. If you find any difficulty or have any query then do COMMENT below. PLEASE help our channel by SUBSCRIBING and LIKE our video if you found it helpful...CYA :)
    ======================================PLEASE DONATE=============================
    🧡 SUPPORT OUR WORK: / techdose
    💚 UPI-ID: surya.kahar@ybl
    💞JOIN Membership: / @techdose4u
    ==============================================================================
    INSTAGRAM : / surya.pratap.k
    LinkedIn: / surya-pratap-kahar-47b...
    WEBSITE: techdose.co.in/
    TELEGRAM Channel LINK: t.me/codewithTECHDOSE
    TELEGRAM Group LINK: t.me/joinchat/SRVOIxWR4sRIVv5...
    =======================================================================
    USEFUL LINKS:
    🟠Must do TIPS to ACE Virtual Interview: ‱ 🔮Must do Tips to ACE y...
    🟱Best strategy to excel your coding interview: ‱ 🔮Best strategy to exce...
    🟡Get your dream job in 1 month: ‱ 🔮Get your dream job in...
    đŸ””How to crack dream job in just 2 months: ‱ How to crack dream job...
    🟣7 Days DSA plan: techdose.co.in/7-days-dsa-che...
    RELATED LINKS:
    Maximum of all subarrays of size K: ‱ Maximum of all subarra...
    Perfect Subarray: ‱ Perfect subarray | Goo...
    CODE LINK: techdose.co.in/trapping-rainw...

Komentáƙe • 245

  • @TW-uk1xi
    @TW-uk1xi Pƙed 3 lety +61

    This is one of the best explanations I've seen so far on the internet.

  • @EngWorld-nr2ww
    @EngWorld-nr2ww Pƙed 3 lety +70

    Your patience while explaining is quite appreciable

  • @gsmdfaheem
    @gsmdfaheem Pƙed rokem +6

    Hands down the best explanation on youtube... Better than top creators.

  • @mwshubham
    @mwshubham Pƙed 3 lety +28

    This might be the longest video on your channel. Very well covered. Thank you :)

    • @techdose4u
      @techdose4u  Pƙed 3 lety +2

      Welcome

    • @abhilashpatel3036
      @abhilashpatel3036 Pƙed 3 lety +1

      i did not even notice. Time flies.

    • @MdOwaisUmar
      @MdOwaisUmar Pƙed 2 lety

      @@abhilashpatel3036 Absolutely, Time flies, but leaves its shadow behind.

  • @user-oy4kf5wr8l
    @user-oy4kf5wr8l Pƙed 3 lety +5

    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!

  • @codingessential91
    @codingessential91 Pƙed 3 lety +7

    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.

  • @rtan8780
    @rtan8780 Pƙed 3 lety +12

    Dang man, you made a Leetcode Hard problem seem like an Easy. Subscribed :)

  • @sugandhaduhan8707
    @sugandhaduhan8707 Pƙed rokem

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

  • @biswajitsingh8790
    @biswajitsingh8790 Pƙed 2 lety

    Hands down the best explanation of this problem on the internet. 🙏🙏

  • @paramitagorai9087
    @paramitagorai9087 Pƙed 2 lety +1

    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.

  • @beginnerprogrammingtutoria5053

    An incredibly detailed and amazing presentation. Thank you!

  • @YashHalgaonkar
    @YashHalgaonkar Pƙed 2 lety +4

    Your channel is really great! You should definitely have more subscriber than most of other creators who create useless roadmaps.

  • @muwongenicholus2444
    @muwongenicholus2444 Pƙed 2 lety +1

    You sir, did an awesome job breaking this down and making it simpler to understand. Thank you for your efforts. Appreciate it

  • @DK-ox7ze
    @DK-ox7ze Pƙed 2 lety +4

    Awesome explanation, covering all cases with detail and clarity!

  • @amitavamozumder73
    @amitavamozumder73 Pƙed 3 lety +2

    It's rare to have a video with zero downvotes! great explanation.

  • @suryajena1575
    @suryajena1575 Pƙed 2 lety +2

    Happy Teacher's day. Really appreciate you as a teacher.

  • @gautam4696
    @gautam4696 Pƙed 3 lety +1

    The solution of this problem is very simple but the way sir tells how to approach a problem is amazing .

  • @PRUTHVIRAJRGEEB
    @PRUTHVIRAJRGEEB Pƙed 3 lety +2

    This is hands down the best explanation I have seen for this question. I am surprised it doesn't have many views!

  • @sanketgupta9831
    @sanketgupta9831 Pƙed rokem

    Best explanation ever with best level of calmness and patience 😊😊

  • @01kumarr
    @01kumarr Pƙed rokem

    giving all three possible solutions u make life easy. Thanks a lot

  • @akashjain4281
    @akashjain4281 Pƙed 3 lety

    The best explanation for the problems, Ty sir for ur patience and amazing explanations

  • @sumeetchawla3545
    @sumeetchawla3545 Pƙed 2 lety

    Thanks a ton for explaining solution in detail. It's really a tough job. Keep it up!!!

  • @sukeshreddy2286
    @sukeshreddy2286 Pƙed 2 lety

    You are the best. I am now sharing with my friends!!

  • @stephc4925
    @stephc4925 Pƙed 2 lety +6

    One of the best explanations! Thanks a lot!

  • @shantanusharma184
    @shantanusharma184 Pƙed 2 lety +2

    Your explanation resolved all my doubts and i was able to write code by myself after watching your video for 10 minutes.
    Thank you

  • @harikakiran18
    @harikakiran18 Pƙed 3 lety +1

    Nicely explained step by step, appreciated it, understood the approach in one go...you deserve more subs & views...hope you will reach there ..:)

  • @mridulsemwal1396
    @mridulsemwal1396 Pƙed 2 lety +2

    No one explains like this.
    Loved your videos

  • @chandrachurmukherjeejucse5816

    So far the best explaination. Thank you so much sir.

  • @coderart__2802
    @coderart__2802 Pƙed 3 lety +1

    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.

  • @ajaygonepuri2285
    @ajaygonepuri2285 Pƙed rokem +1

    You Deserve more than a million subscribers for such a great content!

  • @hnsc1
    @hnsc1 Pƙed 2 lety +2

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

  • @calisthenics-
    @calisthenics- Pƙed 2 lety

    Champ tech dose🙏 👏
    Well done

  • @flyingcanopy5611
    @flyingcanopy5611 Pƙed 3 lety +1

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

  • @varshaprajapati6566
    @varshaprajapati6566 Pƙed rokem

    thankyou so much for this video! you just made this hard task quite easy.

  • @pkboolean
    @pkboolean Pƙed 3 lety +4

    thank you for this, this is extremely well explained

  • @harishkandikatla9791
    @harishkandikatla9791 Pƙed 3 lety +1

    Excellent explanation!
    Your channel will definitely grow a lot

  • @venup2813
    @venup2813 Pƙed rokem

    Most underrated channel

  • @sandeepkharola6463
    @sandeepkharola6463 Pƙed rokem

    Great work
    Keep going 👍

  • @kambalavijay6800
    @kambalavijay6800 Pƙed 2 lety

    Techdose to me is a game changer

  • @prakharagarwal6237
    @prakharagarwal6237 Pƙed 2 lety

    Nice Explanation! Thanks!

  • @jiosim1377
    @jiosim1377 Pƙed 3 lety +1

    Thanks alot! I was struggling to understand the logiv but now its clear

  • @sujitha2339
    @sujitha2339 Pƙed 2 lety

    Clear explanation!! Thanks bro

  • @kushagrashekhawat8227
    @kushagrashekhawat8227 Pƙed 26 dny

    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.

  • @ayushsrivastava830
    @ayushsrivastava830 Pƙed 2 lety +1

    Awesome Explanation, better from other CZcamsrs

  • @aniketroy03
    @aniketroy03 Pƙed 2 lety +2

    Great video sir!! What an explanation! Keep uploading such videos 🙏🙏

  • @atjhamit
    @atjhamit Pƙed 2 lety

    Really good explanation! Thanks a lot.

  • @NaveenRawat51
    @NaveenRawat51 Pƙed 3 lety +1

    awesome explanation, the way you explained corner cases are great. keep it up

  • @ravikumar-kh9gi
    @ravikumar-kh9gi Pƙed 2 lety +1

    Awesome explanation . Even kids can understand after watching this video. Thank you very much

  • @krupaharan9406
    @krupaharan9406 Pƙed 3 lety +1

    This saved my day :-) Thank you very much

  • @basictechs6634
    @basictechs6634 Pƙed 2 lety

    Great explanation, thank you.

  • @chhavimishra3469
    @chhavimishra3469 Pƙed 2 lety

    When the content is so good, subscribing and liking are on autopilot.

  • @huseyinbarin1653
    @huseyinbarin1653 Pƙed 2 lety

    very clear explanation!

  • @trueindian03
    @trueindian03 Pƙed 3 lety

    This was an excellent explanation.

  • @Harsh-og5xr
    @Harsh-og5xr Pƙed rokem

    loved that o(1) space method

  • @athisii_ekhe6167
    @athisii_ekhe6167 Pƙed rokem

    you made it easy. Thank you.

  • @cs-ope
    @cs-ope Pƙed rokem

    Great explanation!

  • @MohitKumar-rq8hv
    @MohitKumar-rq8hv Pƙed 2 lety +1

    TC =O(n)
    SC =O(1)
    => 24:25
    superb explaination

  • @milenitrivedi7561
    @milenitrivedi7561 Pƙed 2 lety

    great explanation !!

  • @santhoshmedide5279
    @santhoshmedide5279 Pƙed 2 lety

    The last solution where time-O(N) and space-O(1) method is amazing. Came here after many leetcode solutions!

  • @yashkhandelwal6588
    @yashkhandelwal6588 Pƙed 3 lety +1

    Thank you so much you explained these questions by previously known methods because others are making it very complicated for reducing code size()

  • @akshitjain2906
    @akshitjain2906 Pƙed rokem

    amazing explanation bro!

  • @SaiKumar-if4lh
    @SaiKumar-if4lh Pƙed 3 lety

    Top notch explanation 👍

  • @CodeSuccessChronicle
    @CodeSuccessChronicle Pƙed 3 lety +1

    Thank you so much for doing this on my request.... best bro...

  • @elitesharma817
    @elitesharma817 Pƙed 3 lety

    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

  • @dayanandraut5660
    @dayanandraut5660 Pƙed 3 lety

    excellent explanation. awesome solution.

  • @PRASHANTKUMAR-xs9pk
    @PRASHANTKUMAR-xs9pk Pƙed 2 lety +1

    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. ::))

  • @huansir1922
    @huansir1922 Pƙed 2 lety +1

    thank you for your explain , from simple solution to better solution !

  • @spaceship-rl5fp
    @spaceship-rl5fp Pƙed 4 měsĂ­ci

    Excellent Explanation

  • @tefradc
    @tefradc Pƙed 3 lety

    Great explanation man,do more

  • @PujaKumari-rp5sg
    @PujaKumari-rp5sg Pƙed rokem

    sir you explained very nicely step by step 👌👌👌

  • @gokulnaathb2627
    @gokulnaathb2627 Pƙed 2 lety

    This was amazingđŸ„ł

  • @nishantpratyush4191
    @nishantpratyush4191 Pƙed 2 lety +1

    I bet this vdo has got the best explanation for the two pointer approach...thanks a ton TechDose😊

  • @sumit180288
    @sumit180288 Pƙed 2 lety +1

    Very good explanation

  • @elenamikhaylova4287
    @elenamikhaylova4287 Pƙed 10 měsĂ­ci

    nicely covered thank you

  • @krishnananddubey2870
    @krishnananddubey2870 Pƙed 3 lety +1

    Just explained it calmly loved that.đŸ€—

  • @gurubalaji5611
    @gurubalaji5611 Pƙed 3 lety +1

    Great explanation sir..hope expecting more videos from tech dose..

  • @arjunadityarastogi2118
    @arjunadityarastogi2118 Pƙed 3 lety

    Thank you , Just THANK YOU

  • @manojbhatt8424
    @manojbhatt8424 Pƙed rokem +2

    brooooooooooooooooo best explaination ever

  • @mpavankumar6695
    @mpavankumar6695 Pƙed 2 lety

    Great explanation

  • @ayeshaadhikari6123
    @ayeshaadhikari6123 Pƙed 2 lety

    Thanks a lot Sir!

  • @neerajpandey7273
    @neerajpandey7273 Pƙed 3 lety +2

    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

    • @techdose4u
      @techdose4u  Pƙed 3 lety +1

      😂 hahaha. Very nice to see you apply the concepts of my previous video :) But there is always someone better than you 😉

    • @neerajpandey7273
      @neerajpandey7273 Pƙed 3 lety +1

      @@techdose4u =D =D

  • @rachanasingh7047
    @rachanasingh7047 Pƙed 3 lety +1

    Best solution explaination to this problem. 🙌

  • @basiljacob3894
    @basiljacob3894 Pƙed 3 lety +1

    Very well explained sir , your explanation for this question is crystal clear. I really liked this problem it was very intuitive

  • @RayTayek
    @RayTayek Pƙed 3 měsĂ­ci

    very nice. thank you

  • @viveknandan4950
    @viveknandan4950 Pƙed měsĂ­cem

    Nice explanation.

  • @ravisankarmaruramesh8112
    @ravisankarmaruramesh8112 Pƙed 3 lety +3

    Index starts from 1 to arr.len-1
    Totalwater+=Math.min(leftmax of current index element, rightmax of current index element)-current index element

  • @nikitakushwaha9572
    @nikitakushwaha9572 Pƙed 2 lety +1

    You are very easy and nice to understand.

  • @sammedsankonatti1579
    @sammedsankonatti1579 Pƙed 3 lety +1

    Best explanation sir. Thank you

  • @venup2813
    @venup2813 Pƙed rokem

    You are legend đŸ”„đŸ”„đŸ”„

  • @simrankak7045
    @simrankak7045 Pƙed 3 lety +1

    amazing crystal clear
    explaination

  • @GauravKumar-ue7nz
    @GauravKumar-ue7nz Pƙed 2 lety

    Best explanation

  • @rugvedb9842
    @rugvedb9842 Pƙed 2 lety

    Thanks a lot!

  • @harshavarthinivr9688
    @harshavarthinivr9688 Pƙed 2 lety +1

    Very nice explanation 👌thank youu

  • @vaishaligoyal7478
    @vaishaligoyal7478 Pƙed 2 lety +1

    Simply Amazing!!

  • @rajivsarkar277
    @rajivsarkar277 Pƙed 3 lety +1

    Ur patience is appreciable

  • @yunusemreozvarlik2906
    @yunusemreozvarlik2906 Pƙed 3 lety +1

    Nice explanation. Thanks!

  • @paragroy5359
    @paragroy5359 Pƙed 3 lety +1

    Nice explanation sir......you are doing a great job

  • @melwinalm
    @melwinalm Pƙed měsĂ­cem

    Such a great explanation

  • @gamingKlips99
    @gamingKlips99 Pƙed 3 lety +3

    what a coincidence that we both were working on the same problem.

  • @khushbukareliya8999
    @khushbukareliya8999 Pƙed 3 lety +1

    Best Explanation.