9 Rain Water Trapping

Поділитися
Вставка
  • Опубліковано 25 січ 2025

КОМЕНТАРІ • 521

  • @punee673
    @punee673 5 місяців тому +11

    This video i watched a year ago definitely got me my job now in my final year. You taught so well i was able to recollect every approach from this. So thanks a ton.

  • @subhajitdutta5216
    @subhajitdutta5216 4 роки тому +256

    Great explanation, and u r right jenny mam is pretty😂

    • @TheAdityaVerma
      @TheAdityaVerma  4 роки тому +158

      right? You feel me ? !! 😂😂😂😂😂😂😂😂😂😂😂

    • @subhajitdutta5216
      @subhajitdutta5216 4 роки тому +4

      @@TheAdityaVerma yup😂🙏, waiting for ur videos though

    • @vivektyson
      @vivektyson 4 роки тому +5

      @@TheAdityaVerma awaaz bhi unka kitna pyaara hai

    • @satishchandra2652
      @satishchandra2652 4 роки тому

      ​@@TheAdityaVerma hahhah

    • @LetszGoo
      @LetszGoo 4 роки тому +9

      haha she is theory teacher. whenever i see her video i thought seh never coded in her whole life.

  • @amanagarwal2022
    @amanagarwal2022 3 роки тому +287

    Jenny kafi achchha padati hai +sunder bhi dikhti hai!
    Koi kinta bhi achcha DSA karle aakhir meh rehata engineer he hai 😂😂

  • @joichirogaming
    @joichirogaming 4 роки тому +25

    The best part of his videos is:
    he explains from starting
    tells all expected approaches and their disadvantages
    and finally tells approach that will give the correct answer
    and then gives the solution.
    Hats off!!!!

  • @devashishbawa8236
    @devashishbawa8236 3 роки тому +138

    15:50 we understand the double meaning laughter 😂😂😂

  • @srajikagupta3627
    @srajikagupta3627 4 роки тому +223

    Volume is very low sir please try to keep it a little more 😅

    • @varungupta420
      @varungupta420 Рік тому +2

      bhaii boats ke headphones se hi sunai de rha merko

    • @abhishekbhowmick5912
      @abhishekbhowmick5912 10 місяців тому +1

      Thanks for this comment, else I would consider this class as mute!

  • @anshmishra3066
    @anshmishra3066 Рік тому +7

    2:12 "dekhna hai to jaaker JENNY k lecture dekho dikhti bhi sundar hai aur acha bhi padhati hai"
    Has a separate fanbase in my college

  • @harishgupta8351
    @harishgupta8351 3 роки тому +15

    Man, Teacher's day never made sense to me before but now after watching these videos, my thinking has changed completely. If teachers in India can focus on developing the thought process in students rather than just completing the syllabus and getting their students in merit list, a lot can change in the country.

  • @sankalparora9261
    @sankalparora9261 4 роки тому +59

    Great video. Damn amazing. You can't imagine what great service you are delivering. I get the idea and I even figure out the whole code in between the video. This is the sign of a great teacher. He just need to give a sign to the student, and the rest becomes a story. You gave me the true picture of what is APPROACH. Otherwise, I was just understanding the idea of the problem or just memorizing how to solve it. You are a CODING GOD.

  • @sadhinoor5114
    @sadhinoor5114 3 роки тому +26

    Bro i really wish i found out about u sooner currently 6th sem passed and watching ur videos for recap......best teacher by far!
    Mad respect bhaiya!:))

  • @dsa9980
    @dsa9980 4 роки тому +27

    Aadi bhai you rock yarr.. !!
    Bhai aapka teaching style todd hai.. ek baar dekhte hi sab samaz aata hai.. bahot dua lagne wali hai aapko sabki..
    You doing a commendable job..!! Hats off yarr..!!
    I hated DS Algo kyunki mujhe bahot tough lagta tha ye sab.. pr ab nahi.. sala kash kisine aisa angle dikhaya hota pehle.. I love solving problems now and successfully able to find patterns in it. Thanks, man..!!
    Keep up the good work..!! Waiting for more..!! God bless.. :-)

    • @TheAdityaVerma
      @TheAdityaVerma  4 роки тому +18

      Thanks brother !! Such long comments always put a smile across my face ❤️✌️✌️
      Also Do share the content amomg your friends and collage to help the channel grow !! Thanks for watching again !!

    • @dsa9980
      @dsa9980 4 роки тому +4

      @@TheAdityaVerma Needless to say.. already shared and received a lot of praise for sharing..!! :D :P

    • @TheAdityaVerma
      @TheAdityaVerma  4 роки тому +6

      Thanks a ton !!

    • @AbhineetDeep
      @AbhineetDeep 4 роки тому +5

      @@TheAdityaVerma bro thoda jor se bola kr pls..

  • @varungoel6981
    @varungoel6981 3 роки тому +80

    Today I got selected in Flipkart all because of your videos Aditya!
    Besides learning technical stuff, I got to learn from you on how to handle and approach complex problems.
    Thanks a lot!
    I really owe you a lot, can't msg on LinkedIn since you haven't accepted my request but I'm gonna ping you as soon as I join to thank you :)

  • @AniketSinha291
    @AniketSinha291 4 роки тому +14

    Very good approach Of breaking down water level at each building level.
    Minor enhancement: the last loop just to calculate sum can be eliminated. You can instead keep adding to sum right after you calculate water level at index i.
    sum += water[i]; // after calculating water[i]

    • @aniketpathak2721
      @aniketpathak2721 2 роки тому +3

      bhai ye toh stack ka sawal tha hi nhi

    • @aloksingh4110
      @aloksingh4110 2 роки тому

      Aditya sir ke aagey mahaanta dikhaaega neech aadmi, jaa jaake ppap dho ganga mein

  • @PrinceKumar-el7ob
    @PrinceKumar-el7ob 3 роки тому +25

    leetcode solution for reference - for noobies like me !!
    int trap(vector& arr) {
    int n =arr.size();
    vector right_max(n);
    vector left_max(n);
    // no matter what we can't store water on edge buildings
    left_max[0]=arr[0];
    for(int i=1;i=0;i--){
    right_max[i]=max(arr[i],right_max[i+1]);
    }
    int sum=0;
    for(int i=1;i

    • @kirtikhohal3313
      @kirtikhohal3313 2 роки тому

      Thanks

    • @shashankbhatgs1150
      @shashankbhatgs1150 2 роки тому +3

      in case someone needs a java solution:
      class Solution {
      public int trap(int[] height) {
      int n = height.length;
      int[] maxL = new int[n];
      int[] maxR = new int[n];

      maxL[0] = height[0];
      for(int i = 1; i < n; i++){
      maxL[i] = Math.max(maxL[i-1], height[i]);
      }
      maxR[n-1] = height[n-1];
      for(int i = n-2; i >= 0; i--){
      maxR[i] = Math.max(maxR[i+1], height[i]);
      }

      int[] water = new int[n];
      for(int i = 0; i

  • @harshkushwaha2212
    @harshkushwaha2212 3 роки тому +26

    Sir, you said you would add the remaining videos later in the playlist. So can you please add them? They are really helping us. Thanks a lot.

  • @amanjyotiparida5818
    @amanjyotiparida5818 2 роки тому +2

    15:52 that 😈 smile...😁😁😁

  • @himanshugusain9022
    @himanshugusain9022 4 роки тому +11

    sir please complete the series , it is much needed. Hats off to your explanation ! if possible add queue playlist also

  • @049_neeraj4
    @049_neeraj4 Рік тому +2

    Explanation was really amazing, but where did we use stack.

  • @poonamchauhan1884
    @poonamchauhan1884 3 роки тому +6

    Commendable work of finding patterns and categorising problems. When will you be adding the last four problems of the list you shared in the beginning of the playlist?

  • @anime4u766
    @anime4u766 3 роки тому +2

    Bhaiya on fire....jenny sundar b lagti h

  • @adityagore2147
    @adityagore2147 Рік тому +1

    2:10 had me going 😂😂😂

  • @ayushagarwal2032
    @ayushagarwal2032 4 роки тому +30

    when are you releasing backtracking playlist?

    • @KartikeyTT
      @KartikeyTT 10 місяців тому +1

      It took him 3 years

  • @Manojrohtela
    @Manojrohtela 5 місяців тому

    Great explanation and Jenny sundar bhi dikhti h savage 😂😂😂😂
    Was confuse with this example
    1,0,2,0,1,3,1

  • @srinivaschaitanya3305
    @srinivaschaitanya3305 Рік тому +1

    kaafi achi padathi hai aur sundar bhi dikthi hai..😂😂

  • @mfaraday4044
    @mfaraday4044 4 роки тому +6

    bhai jitni tarif karu utni kam hai kya content share karte ho aap ,
    ye channel god ka gift hai mere liye aur Aditya verma ( vishnu avatar hai mere life ke liye )

    • @TheAdityaVerma
      @TheAdityaVerma  4 роки тому +9

      Arreyy ni bhai, kaha Vishnuji aur kaha me 😅 Michael Faraday kese bnna hai bs wo bta do 😂✌️
      jokes apart, Thanks for such a beautiful comment, Love you brother 😅✌️

  • @ShubhamKumar-lb9lf
    @ShubhamKumar-lb9lf 4 роки тому +57

    15:52😅😂

  • @jaineshkumar794
    @jaineshkumar794 Рік тому

    👏 Never thought DSA could be so much interesting and easy to learn. These aren't easy problems but hats off to you, after seeing your explanation it's a piece of cake ✌

  • @manaligupta5332
    @manaligupta5332 4 роки тому +5

    The current solution is O(N), O(N) for time and space complexity respectively. A more optimized solution exists using constant extra space O(N), O(1).

    • @yoyocontact5181
      @yoyocontact5181 3 роки тому

      can you please help me ? I wrote the whole code but it is giving me segmentation fault , i cant find where is the mistake
      #include
      #include
      #include
      using namespace std;
      #include
      int trap(vector& height) {
      vectormaxl;
      vectormaxr;
      maxl[0]=height[0];
      for ( int i =1;i=0;i--)
      {
      maxr[i]=max(maxr[i+1],height[i]);
      }
      vectorwater;
      for ( int i =0;i

  • @praveenchouhan6388
    @praveenchouhan6388 4 роки тому +2

    you nailed it!!! I liked the way you have broken the problem down and the concept of maxleft and maxright, awesome, thanks a lot!!!

  • @anupamdubey5736
    @anupamdubey5736 3 роки тому +4

    Thanks a lot for the awesome explanation. I was able to code only by listening to the explanation without seeing the solution. Please keep this channel organic with such content unlike others who at a later stage adulterate their channel with ads and shortcut videos.

  • @jiteshkumar3112
    @jiteshkumar3112 4 роки тому +17

    brother please complete the series by uploading 4 more questions that you gave in your 1 video of stack

  • @SushilKumar-es9ib
    @SushilKumar-es9ib 4 роки тому +1

    Nobody can explain like you. Your explanations makes hardest problem to the easiest problem. Thanks for that

  • @nishantingle1438
    @nishantingle1438 2 роки тому +3

    There is O(1) space complexity solution to it.
    This is indeed related to NGL just nearest is changed to farthest.
    In fact there is no need of stack in NGL, you can just use the same technique to compare with ngl(previous).

    • @anonymous090
      @anonymous090 2 роки тому

      how we can solve it in O(1) ??

    • @kirtikhohal3313
      @kirtikhohal3313 2 роки тому +3

      I don't think we can say this as farthest greater to left:
      suppose this is the array: 6 8 0 0 5 9 6
      for element=5
      max in the left array is 8
      max in the right array is 9
      min of both is 8
      water accumulated on element =5 is 8-5=3. which is correct.
      But, farthest greater to left is 6
      farthest greater to right is 9
      min is 6
      water accumulated is 6-5 =1, which is wrong

  • @deepakdhakad8539
    @deepakdhakad8539 3 роки тому +7

    2:10 yaha boss bhi pighal gye 😂

  • @youcantgetme1126
    @youcantgetme1126 2 роки тому +1

    15:45 so , apne ko smj aa gya ki kese Pani nikal skte h ..😂😂 anyone noticed that he laughed at that moment 😅😅

  • @mohamedfaizan3095
    @mohamedfaizan3095 3 роки тому +1

    2:14 bhaiya op😂😂

  • @mauryaanuj-11
    @mauryaanuj-11 Рік тому +1

    class Solution {
    public:
    int trap(vector& height) {
    int n = height.size();
    vector maxLeft(n), maxRight(n), area(n);

    maxLeft[0]=height[0];
    for(int i=1;i=0;i--){
    maxRight[i]=max(maxRight[i+1],height[i]);
    }

    for(int i=0;i

  • @AbhishekSharma-ip4df
    @AbhishekSharma-ip4df Рік тому

    15:51 his laugh after "tho hame samajh a gaya ki hm kaise paani nikal skte h" Ture engineers😂😂 🙌

  • @sauravdas7591
    @sauravdas7591 4 роки тому +2

    Good Explanation Programming Lord! But Bro, please create the remaining ones in the list, really appreciate your hard work for explaining the concepts. I wished my DSA teacher be like you.

  • @be_like__prateek
    @be_like__prateek 4 роки тому +30

    was expecting the approach using stack. It's nowhere in the utube. DP approach is explained by everyone as it is easy.

    • @kirtikhohal3313
      @kirtikhohal3313 2 роки тому +3

      no doubt , he gave an amazing explanation, but we didn't used stack in this solution, then what's the point of adding this question in the stack playlist?

  • @Missing_man
    @Missing_man Рік тому +1

    2:10 comment on jenny was awesome 😎😎😂😂😂😂😂😂😂😂

  • @lakshkumrawat140
    @lakshkumrawat140 2 роки тому +2

    15:48 kese pani nikal sakte he , and that laughter explains all 😂😂

  • @tanmayjain1584
    @tanmayjain1584 3 роки тому

    Yaar mera to dhyaan bhatak jaata hai ...beech beech may pause kar k bs dil pe haath rakh k hsate rehta hun......kitniiii ppyaari hai ye....
    lekin han bahot achcha pdhati hai jenny mam

  • @deepakffyt2844
    @deepakffyt2844 Рік тому

    Bhai appse aacha koi nahi padtha UA-cam pe ♥️

  • @_AmbujJaiswal
    @_AmbujJaiswal Рік тому +2

    jenny achha padhati h aur sundar bhi dikhti h🤣🤣🤣🤣

  • @baibhavagrawal3441
    @baibhavagrawal3441 4 роки тому

    Sir i am being your big fan
    saala puri duniya patani lakhon kharch karke lecture video suit kar raha he aur bhai apna ek page aur mobile phone se unn sabki le raha he.. God Bless bhai.. Love you..

  • @aloksingh8851
    @aloksingh8851 2 роки тому +2

    I have a doubt here, we didn't use Stacks at all in this solution. I see a stack solution on GFG as well but I can't grasp that, can you please add an explanation for that as well?

  • @lifeexplorer2965
    @lifeexplorer2965 4 роки тому +92

    2:13😂😂

  • @abhineetsingh6720
    @abhineetsingh6720 2 роки тому +3

    "jenny kafi acha padhati hai aur sundar bhi dikhti hai"

  • @babithakumari5884
    @babithakumari5884 Рік тому

    can't thankyou enough for these videos, I can't believe I am able to code faster only by understanding the approach.

  • @ajaybhagchandani3307
    @ajaybhagchandani3307 4 роки тому +1

    This video helped me in solving the leetcode question of Rain water trapping. Thanks alot!

  • @piyushkumar-bl2ck
    @piyushkumar-bl2ck 3 роки тому +4

    Thanks Aditya .
    Constant space - O(1). and single loop solution - O(n)
    void max_water(int A[], int n)
    {
    int l = 0, h = n - 1;
    int left_max = 0;
    int right_max = 0;
    int ans[n] = {0};
    while (l = right_max)
    {
    right_max = A[h];
    }
    else
    ans[h] = right_max - A[h];
    h--;
    }
    }
    for (int i = 0; i < n; i++)
    {
    cout

    • @kirtikhohal3313
      @kirtikhohal3313 2 роки тому +1

      Is it the dp solution??

    • @aryankhanuja4828
      @aryankhanuja4828 2 роки тому

      @@kirtikhohal3313 Dp can not be done without memoisation. This is greedy ig..

  • @ananya_gupta2328
    @ananya_gupta2328 6 місяців тому

    "Vo accha pdhati hai, sundar bhi dikhti hai" was heart touching🤣🤣

  • @adityamane9312
    @adityamane9312 3 роки тому

    what will be the time and space complexity for this problem??

  • @logicoverflow1240
    @logicoverflow1240 3 роки тому

    Bhaiya mooj kara di 🔥🔥🔥 maza aagaya

  • @mrinalkhandelwal9631
    @mrinalkhandelwal9631 4 роки тому +11

    Sir, please upload videos on graph problems: DFS, shortest paths, SCC

  • @strangesoul31
    @strangesoul31 3 роки тому +2

    Still Waiting for Tree,Graph, Backtracking...
    Bhai apko jab bhi time mile to inki video series bana ke upload kr dena🙏🙏🙏

  • @sudipasarkar7981
    @sudipasarkar7981 4 роки тому +2

    areeey you're the best ..i can binge watch your videos

  • @abhishekaggarwal7110
    @abhishekaggarwal7110 Рік тому +1

    one line for Jenny 😂
    kaafi acha pdhati hai and sundar bhi dikhti hai 😂

  • @sampathrajaraghupathikagup8723
    @sampathrajaraghupathikagup8723 3 роки тому +1

    This problem clearly identifies stack . as we go maxleft and maxright element comparing to the current element. So seen the full video and disappointed by not using stack. So I implemented the Stack-based approach its is similar to NGL and NGR but little modifications need to be done.and also similar to above video approach but below code uses stack and above code uses max(arr[i],max[i-1]);
    Note:-All my knowledge is acquired from Aditya verma's channel.
    JAVA CODE
    class Solution{
    // arr: input array
    // n: size of array
    // Function to find the trapped water between the blocks.
    static int trappingWater(int arr[], int n) {
    int sum=0;
    int maxright[]=maxRight(arr,n);
    int maxleft[]=maxLeft(arr,n);
    for(int i=0;i=0;i--)
    {
    if(st.peek()

    • @Raj10185
      @Raj10185 Рік тому

      we don't really need to implement stack in this problem if we use stack our space complexity increases without any benefit so we can just do it using traversing and creating two array instead of stack

    • @TuringTested01
      @TuringTested01 Рік тому

      faltu ka oversmart bann raha hai jaise koi reimann hypothesis ka solution nikal diya ho, jab jarurat nahi hai stack ki aur O(1) space mein bhi hoskta hai toh faltu mein stack kyu ghusedna hai, push pop push pop karne mein maza arha h kya terko

  • @tanzeelurrahman1545
    @tanzeelurrahman1545 3 роки тому

    Add link to problem in your videos.
    TY for the amazing tutorials.

  • @shyamkachhadiya4964
    @shyamkachhadiya4964 7 місяців тому

    wow great problem, solved excellents, there's little maths involved but yea great explanation.

  • @pratik.784
    @pratik.784 Рік тому +1

    stack kha use hua isme?

  • @mainaksanyal9515
    @mainaksanyal9515 4 роки тому +1

    Bhai stack kaha use kiya issme ??

  • @AryanGairola-th3qc
    @AryanGairola-th3qc Рік тому

    Bro tumne khud sikhe ya phle pdhe
    Mtlb one go n develop kiye k solution

  • @rj4uguys
    @rj4uguys 4 роки тому +2

    Awesome work! Why put this in stack playlist?

  • @RahulVerma-fz2jf
    @RahulVerma-fz2jf 4 роки тому +3

    Upvoting because you explained it well, but the video pic (in the starting) mentions, you will be solving it using stack, but you didn't. Please add the stack solution as well.

  • @jaydeepmahajan6598
    @jaydeepmahajan6598 4 роки тому +8

    Explanation is really good but i didn't see stack in this problem

  • @Prodcater
    @Prodcater 3 роки тому +2

    @adityaverma Please discuss the time complexity also for each program ..please it will help a lot

  • @Gauravkr0071
    @Gauravkr0071 4 роки тому

    aditya bhai, tum ho to sb h, vrna kch bhi nhi. dil se dhanyawaad

  • @PraveenKumar-nf4qr
    @PraveenKumar-nf4qr 3 роки тому +1

    How come this problem comes under stacks concept?

  • @PankajGupta-vs2kq
    @PankajGupta-vs2kq 4 роки тому +2

    Time complexity using this method and using stacks is O(n), right?

  • @VintageAnkitYadav
    @VintageAnkitYadav Рік тому +3

    but here we have not used stacks?

  • @ajitdhayal1612
    @ajitdhayal1612 4 роки тому +6

    Jenny kafi achchha padati hai +sunder bhi dikhti hai!
    Sir aapka crush hai sayad😂

    • @TheAdityaVerma
      @TheAdityaVerma  4 роки тому +12

      Tum log badnaam mt kro be, 😂😂 tum logo interest aaye isliye bola tha yaar, yaha to backfire ho gya 😕😅

  • @047gauravkumartiwari5
    @047gauravkumartiwari5 3 роки тому

    Bhaiya mic mars pe rakh ke earth pe video record kar rahe ho kya.

  • @tanmaytyagi7031
    @tanmaytyagi7031 3 роки тому

    can this be done without using extra space??

  • @deveshgarg
    @deveshgarg 3 роки тому +11

    Just pointing out small error..
    We should not add the contribution of negative values of water array in the final sum. Because it is be possible that the current building height may be greater than both the corresponding mgr and mgl values. In that case water array will become negative.

    • @adityasoni3794
      @adityasoni3794 3 роки тому +3

      yeah this is an error in his explanation. While checking the according mxl and mxr values of arr[i], we will include arr[i] in that also. Cause if we check the answer through his explanation (not code) of this arr = [3, 0, 0, 5, 0 4] it'll be wrong.

    • @kirtikhohal3313
      @kirtikhohal3313 2 роки тому +2

      I don't think so his solution is wrong in any way. See if there's a building whose height is the maximum one, then it's mgr and mgl is equal to the height of that building itself. And the amount of water on such a building will come out to be zero. So, in no ways the water array can hold a negative value .

    • @kirtikhohal3313
      @kirtikhohal3313 2 роки тому +2

      Sharing my LeetCode for reference Passing 321/321 cases
      int trap(vector& height) {
      int c=height.size();
      vector left(c),right(c);
      int water=0;
      left[0]=height[0];
      for(int i=1;i=0;i--)
      {
      right[i]=max(right[i+1],height[i]);
      }
      for(int i=0;i

    • @kirtikhohal3313
      @kirtikhohal3313 2 роки тому +2

      @@adityasoni3794 I just checked for this example, the code and logic is working fine for it, it's giving the desired output that is 10 units .

  • @adityamaurya9277
    @adityamaurya9277 4 роки тому +9

    those who learned " pani kaise nikalte hai".....like the video

  • @aadhya2187
    @aadhya2187 Рік тому +2

    Where is stack used in the video🙂

  • @ArpitKumar-yo6up
    @ArpitKumar-yo6up 2 роки тому

    I love your explanation sir

  • @akashbhoi1951
    @akashbhoi1951 3 роки тому +1

    Sundar bhi dikhti hai woh😂🥰🥰

  • @sumtverma7810
    @sumtverma7810 4 роки тому +12

    15:46 ,me as a kid when friend told me about homework folder.

  • @iamvishalaggarwal
    @iamvishalaggarwal 7 місяців тому

    best explanation 🥳

  • @JigsawXop
    @JigsawXop 29 днів тому

    no stack used right?

  • @tarunreddy8243
    @tarunreddy8243 4 роки тому +2

    Similar to histogram but not stacks problem i think . Just arrays

  • @sbrmnd3885
    @sbrmnd3885 4 роки тому +4

    Waiting eagerly for your backtracking playlist. Please release it soon.

  • @AmanKumar-kz1rn
    @AmanKumar-kz1rn 4 роки тому +2

    samshj me agya kaise pani nikalna hai
    thanks bhaiya for such a wonderfull explanation

  • @atharvas4399
    @atharvas4399 4 роки тому +1

    is there a chance they way u setup the initial element of the maxl and maxr arrays is wrong?
    shouldnt the first element of maxl be 0 and the last elem of maxr be 0, since they are surrounded by buildinggs of height 0 and you only look in the left subarray and right subarray and never actually include the element you are on?

  • @roshangupta8161
    @roshangupta8161 11 місяців тому

    15:50 Bro didn't even hesitate!! 😂😂

  • @chandankrjha
    @chandankrjha 3 роки тому

    itna acche se explain kiya hai. dhanyawaad.

    • @yoyocontact5181
      @yoyocontact5181 3 роки тому

      can you please help me ? I wrote the whole code but it is giving me segmentation fault , i cant find where is the mistake
      #include
      #include
      #include
      using namespace std;
      #include
      int trap(vector& height) {
      vectormaxl;
      vectormaxr;
      maxl[0]=height[0];
      for ( int i =1;i=0;i--)
      {
      maxr[i]=max(maxr[i+1],height[i]);
      }
      vectorwater;
      for ( int i =0;i

  • @CodeKickstart123
    @CodeKickstart123 Місяць тому

    What an explanation 😊

  • @subarnasamanta4945
    @subarnasamanta4945 3 роки тому

    Attitude tabar tor hai bhai sahi hai dikhra hai kis level ka preparation hai aur really approach kafi different aur accurate hai

  • @rishabhbatra3022
    @rishabhbatra3022 3 роки тому

    Bhai gfg p isqe 5 solution h... To kya vo sArey krne pdege..? Ya fir bs ek o(n2) vala aur ek ye jo apne btaya h O(n) with using space...

    • @yoyocontact5181
      @yoyocontact5181 3 роки тому

      can you please help me ? I wrote the whole code but it is giving me segmentation fault , i cant find where is the mistake
      #include
      #include
      #include
      using namespace std;
      #include
      int trap(vector& height) {
      vectormaxl;
      vectormaxr;
      maxl[0]=height[0];
      for ( int i =1;i=0;i--)
      {
      maxr[i]=max(maxr[i+1],height[i]);
      }
      vectorwater;
      for ( int i =0;i

  • @Rajjain_
    @Rajjain_ 3 роки тому

    sunder bhi dikhti hai who😂, But you are the best!

  • @jitengarg5740
    @jitengarg5740 3 роки тому

    bhai bohot badiya thi vedio :)
    pr avaj bohot kam hai
    jis karan earphone lagane pad te hai
    aur jada time earphone lagane muskil hai

  • @dheerajpoonia2175
    @dheerajpoonia2175 4 роки тому +1

    awesome sir, koi word nhi hai apki tarrif krna ka bss jaab selection honne ke baad sweet lekr faculty k pass too pta nhi jaoga ya nhi but appke pass jurur aaoga :-)

  • @ankitparashar6370
    @ankitparashar6370 3 роки тому

    Why is this question included in the stack playlist? You didn't use stack anywhere in this question.

  • @DeathNote-nf3zo
    @DeathNote-nf3zo Рік тому

    class Solution {
    public:
    int trap(vector& height) {
    vectorleft(height.size());
    vectorright(height.size());
    left[0]=height[0];
    right[height.size()-1]=height[height.size()-1];
    for(int i=1;i=0;i--)
    {
    right[i]=max(right[i+1],height[i]);
    }
    vectorans(height.size());
    for(int i=0;i

  • @Anand-zg6jv
    @Anand-zg6jv 4 роки тому

    Bhai or SB topic pe videos dalo na .... Bhut Shi samjh Mai aata tumhari video se

  • @nityaranjan6714
    @nityaranjan6714 9 місяців тому

    But is main stack kahan laga? Ye problem stack ke playlist main kyun hai?