Lecture 56: Largest Rectangular Area in Histogram [Optimised Approach]

แชร์
ฝัง
  • เผยแพร่เมื่อ 20 ก.ย. 2024

ความคิดเห็น • 292

  • @jaygupta2552
    @jaygupta2552 2 ปีที่แล้ว +111

    Sorry but this was a little fast and so some concepts did not hit well ...usually this does not happen .. but I felt it today ....

    • @tip7912
      @tip7912 หลายเดือนก่อน

      Nah bro even I watched it in 1.25x don't worry bro just be consistent you will able learn everything one day

    • @janiparam7894
      @janiparam7894 หลายเดือนก่อน +1

      bro watch it on 0.5x...!😅

    • @appy4401
      @appy4401 29 วันที่ผ่านมา +1

      skill issue

    • @prashantawasthi6825
      @prashantawasthi6825 20 วันที่ผ่านมา

      @@appy4401 tmhare me bahut skill hai to video kyu dekhne aae. BC kam pela karo beta.

  • @shreyasnaphad3284
    @shreyasnaphad3284 2 ปีที่แล้ว +73

    Keep posting, the content is seriously amazing. Awesome work rate! Eagerly waiting for the advanced dsa concepts such as tree graph etc.

  • @haiderali0801
    @haiderali0801 2 ปีที่แล้ว +45

    Literally, the best course on DSA.
    Thankyou bhaiya.✨

  • @rishu4225
    @rishu4225 ปีที่แล้ว +3

    00:00:00 - Intro
    00:00:03 - Stack implementation, medium to hard level questions
    00:03:15 - Doubt support, structured courses,
    00:06:40 - Stack implementation for finding smaller elements in an
    00:12:18 - Finding next/previous smaller element, largest
    00:16:56 - Loop, area, optimization, stack,
    00:23:05 - max area, problem with next, prev
    created using timestampgenius

  • @hardikshukla4508
    @hardikshukla4508 ปีที่แล้ว +16

    It took me to watch this video twice, but the histogram problem is best explained by you bro, THANKS :)

  • @saumitramuley5170
    @saumitramuley5170 2 ปีที่แล้ว +16

    Bhaiyya You Are Doing great work Thank You Bhaiyya For everything All Concept are crystal clear till this thank you for next level consistancy❤️

  • @prayagpatel9136
    @prayagpatel9136 2 ปีที่แล้ว +22

    i have understood the code, but like how in the world can we think of this approach if we have not seen such question before?

    • @sde77
      @sde77 7 หลายเดือนก่อน +1

      yes, so did you get any insight regarding this bro. Please tell me

    • @deeksha-cm8kq
      @deeksha-cm8kq 2 หลายเดือนก่อน +1

      @@sde77 actually there are some standard algorithms that we have to remember there's no way you can always solve all the questions all by yourself in the first go.

    • @PriyanshuYadav-wk1ck
      @PriyanshuYadav-wk1ck 2 หลายเดือนก่อน

      @@deeksha-cm8kq what are those algorithm

  • @iEntertainmentFunShorts
    @iEntertainmentFunShorts 2 ปีที่แล้ว +15

    Completed bhaiya, now I feel confident in stack and recursion
    I'm only able to understood recursion bcoz of you ❤.. like how to approach a recursion problem or how to convert an iterative solution to a recursive one. Thank you so much bhaiya Will try to reach tree by Sunday.

    • @xreesh
      @xreesh 2 ปีที่แล้ว

      tree ho gaya??

    • @alexrcrew1975
      @alexrcrew1975 2 ปีที่แล้ว +1

      @@xreesh hn

  • @uttamkesarwani6143
    @uttamkesarwani6143 2 ปีที่แล้ว +12

    We need Handwritten Notes rest of Lectures, It's really time savings.
    When we have to revise, then I think all of us use that beautiful Notes.
    Otherwise it again a long time to see video again.

  • @yashaggarwal6013
    @yashaggarwal6013 ปีที่แล้ว +5

    Q1 mein jo 2nd approach hain usmein bhi toh Time Complexity O(n^2) hogi kyuki FOR Loop ke andar WHILE Loop use kiya hain .

    • @yashaggarwal6013
      @yashaggarwal6013 7 หลายเดือนก่อน

      @Vishwesh_ Well, I would have appreciated if you would have simply explained about time complexity instead of commenting your stupidity.

  • @sangrambiradar9461
    @sangrambiradar9461 2 ปีที่แล้ว +21

    Keep Working and Keep believing myself that i can do this and trying to match your consistancy everyday.

  • @ritikamehta9791
    @ritikamehta9791 2 ปีที่แล้ว +21

    Present sir✌🏻 enjoying the series !!Great work sir💯💯

  • @taxila4047
    @taxila4047 ปีที่แล้ว +9

    I was stuck on this lecture from two days finally I have completed it.I am so happy.

  • @_SOHAMSAMANTA
    @_SOHAMSAMANTA 2 ปีที่แล้ว +7

    Bro you teach really good!!! Though i code in java , but ur explanation is suitable for any language. Thank You so much for these videos.

  • @deeppatel0586
    @deeppatel0586 ปีที่แล้ว +1

    you can also store the smallest element in an integer while filling the stack and push ("smallest" or "-1") as the condition demands

  • @aryanmaniyar3475
    @aryanmaniyar3475 11 หลายเดือนก่อน +1

    Bahut hi badhiya video bhaiya/sir !! Love the way ki aap kaise pehle ek related question solve karwaate ho, taaki hum log wo idea main question me laga sake :)

  • @sureshmakwana8709
    @sureshmakwana8709 6 หลายเดือนก่อน

    Algo 2 :
    1. Will keep going right untill we get bigger or equal height rectangle. So max width for that triangle can be next-prev-1. (Prev can be -1 in can case of no smaller rectangle on left side )
    2. For this formula to be valid the next has to be greater than 0 otherwise 3 or 2 negatives can make width/breadth in negative which is not right

  • @tusharnain6652
    @tusharnain6652 2 ปีที่แล้ว +7

    There is still a better approach in Striver's channel

  • @suvigyabasnotra7378
    @suvigyabasnotra7378 2 ปีที่แล้ว +31

    Har video mein at least 2-3 Leetcode ke Medium se Hard level wale questions zarur karwao aur length 45 min se 1 hr tak jaane do.

  • @vishwakarma-gaurav
    @vishwakarma-gaurav 2 หลายเดือนก่อน

    Really helpful !!. I tried doing the histogram problem just after the 1st problem and solved it in one Go
    you are amazing babbar bhaiya !!!!!!

  • @sumanpaul8794
    @sumanpaul8794 2 ปีที่แล้ว +5

    Seriously best course on DSA. Keep posting such amazing content 💯

  • @vedant6460
    @vedant6460 2 ปีที่แล้ว +3

    Thanks a lot Love Bhai!! This series is really helpful for us.
    Your efforts are next level man!
    💯💯

  • @r060zeeshankhan9
    @r060zeeshankhan9 2 ปีที่แล้ว +1

    bhaiyya apka content bohot accha hai , bass thoda clear bola karo , kuch words aap jaldi jaldi me boldete ho toh samajh nahi aate ....

  • @amanprajapati6301
    @amanprajapati6301 9 หลายเดือนก่อน +1

    Bhaiya loop ke ander while loop hai to time complexity jese n^2 hui
    Please comment

  • @TechUprise-by-Jyoti
    @TechUprise-by-Jyoti 2 ปีที่แล้ว +3

    Thank you so much bhaiya! Consistency OP 😇😊✨

  • @HarshRaj-kp7gk
    @HarshRaj-kp7gk 2 ปีที่แล้ว +4

    Sir , aptitude and resonaning series kab se start hogi approx date reply sir 🙏🏾🙏🏾

  • @harshpandey4190
    @harshpandey4190 ปีที่แล้ว +1

    It's Giving Confidence

  • @harshitakoranga4588
    @harshitakoranga4588 13 วันที่ผ่านมา

    This is my 5-6 video and finally got it.🤩

  • @Harsh-z2x
    @Harsh-z2x 2 หลายเดือนก่อน +1

    How did that code run in ques 1. If we take a case in which arr=[5,6,2,1,-2] here arr[n-1]=curr=-2 and s.top()=-1 so s.top()>arr[i] hene while loop would run and s.pop() pops out the only element in the stack hence stack is empty then how ans[i] gets -2 store in it

    • @educulture1004
      @educulture1004 2 หลายเดือนก่อน

      Constraints me arr[i] >= 0 diya hua hai

  • @Lucifer-xt7un
    @Lucifer-xt7un 2 ปีที่แล้ว +2

    God level consistency 🙌🙌

  • @ayushrawat7951
    @ayushrawat7951 2 ปีที่แล้ว +1

    Amazing question with amazing explanation ❤..... Undoubtedly, pretty good course than anyone

  • @gauravbanerjee2898
    @gauravbanerjee2898 ปีที่แล้ว +1

    Op explanation bhaiya ❤ Hard problem ko ekdam easy bana dia 🔥

  • @PriyanshuSrivastava11fig
    @PriyanshuSrivastava11fig 2 ปีที่แล้ว +2

    Present bhaiya!!! Awesome series and consistency ♥️♥️

  • @ShubhamPatidar16
    @ShubhamPatidar16 2 ปีที่แล้ว +1

    TBH, best dsa on youtube 🔥

  • @manasraikaushik864
    @manasraikaushik864 2 หลายเดือนก่อน

    19 ms code for first que , yaha while loop k place pe direct i++ krde to complexity kam ho jati hai .....stack s;
    s.push(-1);
    for(int i=n-1;i>=0;i--)
    {
    int z= arr[i];
    if(s.top()

  • @prashantbirajdar9271
    @prashantbirajdar9271 2 ปีที่แล้ว +1

    wahh bhaiyaa mzaa aa gyaa...hats off to you bhaiyaa..keep it up for ourself...

  • @smartannu
    @smartannu 2 ปีที่แล้ว +2

    awesome ..........
    waiting for dp and backtracking .✌

  • @prathmeshparteki1016
    @prathmeshparteki1016 2 ปีที่แล้ว +1

    Present bhaiyya... 🤩 Great consistency

  • @onkardheemate1066
    @onkardheemate1066 ปีที่แล้ว

    are bhaiya tu si great ho .. it takes time to me understand bt your explanation is superb

  • @archanjash2102
    @archanjash2102 2 ปีที่แล้ว +1

    Thank you ❤️ bhaiya.. consistency OP.. ❤️

  • @v4vish147
    @v4vish147 ปีที่แล้ว +1

    not explained well striver's explanation is quite good though

  • @iutkarshmehta
    @iutkarshmehta 2 ปีที่แล้ว +2

    Consistency op🔥🔥
    Reach++

  • @tunapradhan7571
    @tunapradhan7571 2 ปีที่แล้ว +2

    Bhai approximately kitne total lecture honge

  • @shreyansh-s
    @shreyansh-s 2 ปีที่แล้ว +1

    if the array contains negative no this algo will fail., {,2,1,3,-5} ,in first iteration of while loop, -1>=-5 so -1 will be popped then stack will be empty but while loop will still run for -5 as there is nothing left in stack, segmentation fault will occur, correct me if i am wrong.

    • @04_abhishekpandey37
      @04_abhishekpandey37 2 ปีที่แล้ว +1

      yes. but according to question, height can't be negative😅

    • @shreyansh-s
      @shreyansh-s 2 ปีที่แล้ว

      @@04_abhishekpandey37 i was talking about first quesn, now i get it for first quesn it is given array contains +ve no only

    • @04_abhishekpandey37
      @04_abhishekpandey37 2 ปีที่แล้ว

      @@shreyansh-s ooh okay cool👍

    • @softwarefoodiee
      @softwarefoodiee ปีที่แล้ว +1

      Then you have to push INT_MIN initially in the stack instead of -1.

  • @Niki_0011
    @Niki_0011 11 หลายเดือนก่อน

    Thoda thoda doubt hai per dry run se hoo jayega ❤ thanku Bhaiya maja aa gya

  • @mr.invisibale5570
    @mr.invisibale5570 ปีที่แล้ว +1

    this next greater elements code will not work for 1 3 4 2................plz try

  • @m.afnan2018
    @m.afnan2018 2 ปีที่แล้ว

    Ye toh meine socha hi ni,,, Nice Approach bhaiya and well explained !!!!

  • @udaypratapsingh8923
    @udaypratapsingh8923 2 ปีที่แล้ว +1

    love u bhaiya ❤️❤️❤️

  • @vinaygupta2369
    @vinaygupta2369 2 ปีที่แล้ว +1

    great hardwork bhai, thanks for everything ❤️

  • @vishalgarna4580
    @vishalgarna4580 ปีที่แล้ว +1

    Best se bhi best 😊😊

  • @sarangkumarsingh7901
    @sarangkumarsingh7901 2 หลายเดือนก่อน

    This is just AWESOME . Enjoyed it.

  • @pranavmuley3134
    @pranavmuley3134 2 ปีที่แล้ว

    🔥🔥🔥❣awesome playlist on youTube.
    Never seen before.

  • @studygainer5482
    @studygainer5482 ปีที่แล้ว +1

    awesome content sir

  • @learncoding-df7lq
    @learncoding-df7lq 8 วันที่ผ่านมา

    love you bhaiya for you best content

  • @harshsharma396
    @harshsharma396 ปีที่แล้ว

    brute force :-
    int maxArea = 0;
    for(int i = 0; i=0 && arr[k] >= arr[i] )
    {
    currArea = currArea + arr[i];
    k--;
    }
    maxArea = max(maxArea , currArea);
    }
    return maxArea;

  • @abhishekverma1528
    @abhishekverma1528 2 ปีที่แล้ว

    consistency on peak. tahnk you bhaiya

  • @Mb-nr5nz
    @Mb-nr5nz 2 ปีที่แล้ว +1

    Bhaiya morning 4-5 am ko aap kuch start krne wale the na questions solve krne ka , please krdo shuru , hum bhi solve karenge aapke sath , ek Poll share krdo phir decide Krna start Krna ya nhi, please bhaiya 🙂❤️

    • @ayushkushwaha171
      @ayushkushwaha171 2 ปีที่แล้ว +2

      Already bohot load hai bhaiya pe yaar..full time job, teaching consistently, maintaing discord, networking to get more teachers to teach other subjects,etc..pehle ye khatam kar lene do 🙂

  • @abhyaskanaujia3862
    @abhyaskanaujia3862 2 ปีที่แล้ว +1

    Thank you so much for all your efforts.

  • @pulkitjain5159
    @pulkitjain5159 2 ปีที่แล้ว +1

    really u explained in a very great way thank you:)

  • @259_parthpatidar9
    @259_parthpatidar9 2 ปีที่แล้ว +6

    #include
    vector nextSmallerElement(vector &arr, int n)
    {
    /*
    //BRUTE FORCE
    for(int i=0;i

  • @JaswanthKumarMadineni
    @JaswanthKumarMadineni ปีที่แล้ว +2

    thoda sa fast hogai iss video

  • @SalesforceBuddy07
    @SalesforceBuddy07 2 ปีที่แล้ว

    Hello , Bhiya thanks you for your lovely teaching and guidance...
    Mei abhi lecture no. 14 pr hui...apko thanks karne ke liye es video pr click kiya⭐

  • @yashshrivastava1134
    @yashshrivastava1134 3 หลายเดือนก่อน

    best solution i have ever found

  • @nishankdeep3084
    @nishankdeep3084 2 ปีที่แล้ว

    thank you bhaiya,understood the concept very well

  • @IrfanKhan-cz3ve
    @IrfanKhan-cz3ve 3 วันที่ผ่านมา

    not understande last question using stack histogram but i do this using brot forse aprroch
    thanks

  • @CforCoding455
    @CforCoding455 10 หลายเดือนก่อน

    Bhai you are using while loop in for loop how it can O(n) it is O(n^2) time complexity

  • @shivamgupta-kv8dy
    @shivamgupta-kv8dy ปีที่แล้ว

    Brute force for Largest Area of rectangle -
    class Solution {
    public:
    int largestRectangleArea(vector& heights) {
    int maxArea = 0;
    for(int i = 0;i= 0){
    while(heights[j]>=heights[i] && j>=0){
    width++;
    if(j>0){
    j--;
    }
    else{
    break;
    }
    }
    }
    int k = i + 1;
    if(k < heights.size()){
    while(heights[k] >= heights[i] && k

  • @aryanvyas6207
    @aryanvyas6207 2 ปีที่แล้ว +1

    Why is time complexity O(n) only in Question 1 ?

    • @ASMR-bu8qc
      @ASMR-bu8qc 2 ปีที่แล้ว

      I also have this confusion. jab for loop me while agya, to O(n) nhi hona chahiye tha.

  • @jatingarg1897
    @jatingarg1897 2 ปีที่แล้ว

    You are doing an awesome work Bhai!. Hope to get a good placement soon.

  • @mohammadamaan9410
    @mohammadamaan9410 ปีที่แล้ว

    what will be the ans in next smaller element in case of [5,1,4,3,10,2]. here is the problem with your approach, at when we'll find next smaller for element 4 at that time stack has two smaller element than 4. stack would be like [3,2,-1] and s.top() will be = 3. then how to deal with this case ?
    @codeHelp

  • @amitramshinde
    @amitramshinde 10 หลายเดือนก่อน

    in the second approach time complexity id o(n^2) an

  • @samyaknagrale9566
    @samyaknagrale9566 ปีที่แล้ว

    Present bhaiya!!! Thank you so much

  • @culeforever5408
    @culeforever5408 9 หลายเดือนก่อน +1

    understood

  • @torus151
    @torus151 2 ปีที่แล้ว

    Hard level karwa diya.....maza aagaya bhaiya

  • @AA-wy9vw
    @AA-wy9vw 2 ปีที่แล้ว

    Loving the series.

  • @sachitdhamija1884
    @sachitdhamija1884 2 ปีที่แล้ว

    bhaiya area vaala thoda samajha nhi but baki sab thik h ,do tin baar dekhta ho aajeyaga
    some amt of time ab done hota h aur clear bhi lage raho

  • @RohitSingh-hc8yi
    @RohitSingh-hc8yi ปีที่แล้ว +1

    Loving the content

  • @rachit_joshi
    @rachit_joshi 5 หลายเดือนก่อน

    Thank You So Much BHRATA SHREE !!!!!!!

  • @Night_codder
    @Night_codder หลายเดือนก่อน

    bhaiya aap jo questions karate ho vo hame pehle try karna hai ya aap ki video dekhne ke bad karna hai plz ans dena bahaut confusion hai

  • @cat-codes1on1
    @cat-codes1on1 2 ปีที่แล้ว

    aaj hi lec 55 complete kiya now watching todal lec 56

  • @RitikSingh-oh3sj
    @RitikSingh-oh3sj ปีที่แล้ว

    maga aa gaya bhaiya question solve karnai mei

  • @webdevsumit8311
    @webdevsumit8311 2 ปีที่แล้ว +1

    One new pen color is introduced in this video.....

  • @KD_MEENA
    @KD_MEENA 2 ปีที่แล้ว +1

    Bhaiya aap lagbhag 200 videos banana DSA par aesa course pure TH-cam jagat par nahi hoga

  • @KrishKk-x6u
    @KrishKk-x6u 13 วันที่ผ่านมา

    ❤❤❤ best'est' dsa lec..

  • @tarentula8103
    @tarentula8103 2 ปีที่แล้ว

    Every person who ask me how to start coding and also ask about best dsa channel i just say search dsa by love babbar🔥🔥

  • @ujjwalpratap8729
    @ujjwalpratap8729 2 ปีที่แล้ว

    Literallly, the god level Consistency
    present ++

  • @ayushp4471
    @ayushp4471 2 ปีที่แล้ว

    BEST explanation as always❤🔥

  • @suvigyabasnotra7378
    @suvigyabasnotra7378 2 ปีที่แล้ว +1

    12:41 Of course chalega, 44 minutes pehle bhi toh kiya tha. 😂

  • @chinmaykumarsahu3097
    @chinmaykumarsahu3097 2 ปีที่แล้ว +1

    hey! bro while doing any question how to know that the question will solve using stack ??

    • @ASMR-bu8qc
      @ASMR-bu8qc 2 ปีที่แล้ว

      IMO, if we are able to judge that the latest result is required first, we can opt for stack.

  • @harshwardhanchaube706
    @harshwardhanchaube706 2 ปีที่แล้ว

    thank u so much for your 450 qs dsa sheet

  • @ravivishvas3676
    @ravivishvas3676 2 ปีที่แล้ว

    great concepts got easily

  • @udaypratapsingh8923
    @udaypratapsingh8923 2 ปีที่แล้ว

    bhaiya done with today`s lecture .. waiting for another one .. stack ko faad dena hai

  • @RajKumar-vq1nm
    @RajKumar-vq1nm 2 ปีที่แล้ว

    Great Maza agaya..kya step by step utha kar samjhaye ho bhaiya....pehla next small and prev small ka hi game tha..Great explanation.

  • @vipulrohilla1383
    @vipulrohilla1383 2 ปีที่แล้ว

    Best explanation Thanks Bhya

  • @dwivedi6037
    @dwivedi6037 2 ปีที่แล้ว

    Attendance marked bhaya Love u 🙈🙈🙈🙈🙈🙈

  • @unboxtheuniverse5336
    @unboxtheuniverse5336 2 ปีที่แล้ว +3

    Video in AfterNoon😍😍
    Bhaiya plz make a *Roadmap for internship { 5 months left } with DSA busted course as resource* 💥😍
    {2nd Year Students}
    #BeliveInBabbar 😍

    • @sachin-ll1by
      @sachin-ll1by 8 หลายเดือนก่อน

      bhai kaha intern laga?

    • @unboxtheuniverse5336
      @unboxtheuniverse5336 8 หลายเดือนก่อน +1

      @@sachin-ll1by 2 month nhi lagi thi 🤣🤣 6 month lag gyi

    • @sachin-ll1by
      @sachin-ll1by 8 หลายเดือนก่อน

      @@unboxtheuniverse5336 congo... Kis company me?

  • @srinureddy378
    @srinureddy378 ปีที่แล้ว

    Can we do it this way ? , first we will sort individual rectangles in order (increasing height), so that we don’t have to check the previous rectangle,

    • @deepakmajhi6385
      @deepakmajhi6385 ปีที่แล้ว

      no if there is a 0 between two heights then we get wrong ans.[2,0,2]

  • @Trading_Banknifty
    @Trading_Banknifty 9 วันที่ผ่านมา

    Very GOOD BHAIYA

  • @abhishekmasali5351
    @abhishekmasali5351 2 ปีที่แล้ว

    ekdam badiya bhaiya
    mazaa aa gaya👍👍🤩🤩🤩🤩🤩🤩🤩🤩🙏🙏

  • @navdeepkumar4330
    @navdeepkumar4330 2 ปีที่แล้ว

    Great explanation sir💥