Coding Interview Problem - Largest Rectangle In Histogram

Поділитися
Вставка
  • Опубліковано 26 гру 2024

КОМЕНТАРІ • 55

  • @nupurkumar8781
    @nupurkumar8781 3 роки тому +17

    Finally makes sense! After reading multiple articles and watching other videos, this one finally connected all the dots for me. Thank you for the clarity!

  • @gmanjapan
    @gmanjapan 3 роки тому +8

    Thank you for the explanation. Much better than others.
    There's a bug in your pseudo code toward the end - following the python style where your code blocks are indicated by indentation, before you settle on appending a 0 to the end of the heights you had an example of emptying the stack, but that code is indented to be inside the loop instead of after the loop.

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

    Understanding thought process helps in solving not just one problem but a lot of similar problems. Love how your code evolved with your thought process.

  • @naheedray
    @naheedray 4 роки тому +13

    I didn't thought the content would be that great. It turned out to be the best. Thanks for saving my day💜

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

    Now, this is what I call a complete end to end solution. I went through other explanations with no luck. You did an awesome job explaining with such clarity and quality. Tremendous job. Thanks a lot. Keep it up!

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

    Damn. This question finally makes sense. I have been scrounging the internet to find a proper explanation for this question. Thank you kind sir!

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

    Really great video.... please please upload more !!

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

    This is the Best Explanation for the problem out there. Simply WoW!

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

    smart solution and clear explanation

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

    Omg thank you for this! None of the other vids i checked added any clarity.. but this definitely did! Your animations really helped

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

    This is the way to explain algorithms, great work!!!

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

    This is the only solution that explained the intuition. Thank you so much!

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

    I have watched 5 videos for understanding the solution and finally in the 6th video I understood the solution. And this is the 6th one
    Thank you

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

    For anyone looking to get comfortable with mid-level algorithm problems, this is one of the best resources here.

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

    Great explanation! Thanks a lot.

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

    Love your explanations. Very high quality and I encourage you to please release more of them .

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

    7:47 good explaination!

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

    13:57 why do you push the current height, height[i] , when you are adding the shorter rectangle when height[i] is greater than hstack.peek()? Shouldn't that happen when heights[i] is LESS than hstack.peek()?

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

    Great explanation, thanks

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

    i watched number of videos and read articles, ,but histogram problem i never could solve. I got the code too, but still i could not understand the inner while! Finally I have a grasp over it.

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

    I really love the thought process and explanation. Thanks a bunch! :)

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

    GREAT explanation. thank you.

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

    By far the best solution on this topic. Thank you very much sir.

  • @l.k3072
    @l.k3072 4 роки тому

    This is awesome video. BF approach first, analysis, and drive improved solution from there.

  • @AmitKumar-sj9gr
    @AmitKumar-sj9gr 4 роки тому

    Kudos Boss, tried 2-3 videos to understand, but this video finally made picture clear, Great work.

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

    thanks man, really helped !!

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

    Great Explanation.!! It would be great if you upload videos for more DS problems. Thank you

  • @乾淨核能
    @乾淨核能 4 роки тому +2

    I love how you explain you train of thoughts and adjust you pseudo code accordingly. Thank you so much!

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

    This was a real good explanation.

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

    Really really great explanation!!! Others only told the process but this explanation told why are we doing that process....especially I was not getting why are we pushing the elements int the stack....but now I got that actually we are tracking rectangles by doing so.....Thank you very much!!!

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

    Very good explanation

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

    Thanks for this awesome video. what i liked most is correcting the algorithm on the go,while learning this is a good approach. Thanks once again.
    PS: i have used single stack with value and index.

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

    I enjoyed your video. You explained well. It is the best video regarding this topic. Where can I find the code? What is the link of Knapsak website? Thanks, Sophia

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

    Awesome explanation!!!

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

    Great quality

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

    Would it be possible to push onto the stack before popping it off the rectangle? Would that help with being able to end the histogram with all rectangles popped off?

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

    I think the brute force approach will fail when you have minimum height at the end because it 'j' will encounter minimum height every time and will calculate area with respect to that only!!

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

    Great video, thank you!

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

    Very clean explanation, keep it up!

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

    Forgive my ignorance but why is the width (j-i+ 1) in the brute force? I don't understand why we added 1 to it.

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

    What will be the time complexity.

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

    Thanks

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

    will this work if you input 1 2 3? It seems like it will never get into the while loop.

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

    Could you give a working code here. Since I still failed the test. Thanks!

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

    Doesn't the brute force algorithm fail for {3 ,1} ?

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

      I think it would still work. On the first iteration i==j==0 so minheight would be 3 which would be our answer.

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

      @@KnapsackLabs Yup, got it , thanks !

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

    what if there are some rectangle with 0 height?

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

    Damn too good!

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

    ye to sach hai ki bhagwan hai