Coding Interview Problem - Largest Rectangle In Histogram

  Рет қаралды 18,071

Knapsack

Knapsack

Күн бұрын

Пікірлер: 55
@nupurkumar8781
@nupurkumar8781 3 жыл бұрын
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 жыл бұрын
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.
@SameerSrinivas
@SameerSrinivas 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!
@naheedray
@naheedray 4 жыл бұрын
I didn't thought the content would be that great. It turned out to be the best. Thanks for saving my day💜
@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!
@iminsane7777
@iminsane7777 3 жыл бұрын
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.
@arungoli9060
@arungoli9060 4 жыл бұрын
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 жыл бұрын
For anyone looking to get comfortable with mid-level algorithm problems, this is one of the best resources here.
@redomify
@redomify 3 жыл бұрын
Omg thank you for this! None of the other vids i checked added any clarity.. but this definitely did! Your animations really helped
@AbhrajyotiKundu00
@AbhrajyotiKundu00 3 жыл бұрын
This is the Best Explanation for the problem out there. Simply WoW!
@samarthsoni6103
@samarthsoni6103 3 жыл бұрын
Really great video.... please please upload more !!
@kunzhou5159
@kunzhou5159 3 жыл бұрын
This is the only solution that explained the intuition. Thank you so much!
@lindalee3879
@lindalee3879 3 жыл бұрын
I really love the thought process and explanation. Thanks a bunch! :)
@yadhunandhanr7590
@yadhunandhanr7590 4 жыл бұрын
This is the way to explain algorithms, great work!!!
@kunzhou5159
@kunzhou5159 3 жыл бұрын
The ONLY way.
@AmitKumar-sj9gr
@AmitKumar-sj9gr 3 жыл бұрын
Kudos Boss, tried 2-3 videos to understand, but this video finally made picture clear, Great work.
@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.
@budsyremo
@budsyremo 2 жыл бұрын
Love your explanations. Very high quality and I encourage you to please release more of them .
@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!!!
@sharkdeng9253
@sharkdeng9253 3 жыл бұрын
smart solution and clear explanation
@ghanalkaushik2058
@ghanalkaushik2058 4 жыл бұрын
By far the best solution on this topic. Thank you very much sir.
@l.k3072
@l.k3072 3 жыл бұрын
This is awesome video. BF approach first, analysis, and drive improved solution from there.
@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.
@leontylahman5455
@leontylahman5455 3 жыл бұрын
Great explanation! Thanks a lot.
@TheNobodyscat
@TheNobodyscat 3 жыл бұрын
GREAT explanation. thank you.
@rafaelcavalcantechaves81
@rafaelcavalcantechaves81 3 жыл бұрын
Great explanation, thanks
@jwang3417
@jwang3417 3 жыл бұрын
7:47 good explaination!
@乾淨核能
@乾淨核能 3 жыл бұрын
I love how you explain you train of thoughts and adjust you pseudo code accordingly. Thank you so much!
@pravinranjan
@pravinranjan 3 жыл бұрын
Great Explanation.!! It would be great if you upload videos for more DS problems. Thank you
@HienNguyenTechIO
@HienNguyenTechIO 4 жыл бұрын
Very good explanation
@ravikhinchi7067
@ravikhinchi7067 2 жыл бұрын
thanks man, really helped !!
@pranjalyadav7917
@pranjalyadav7917 3 жыл бұрын
This was a real good explanation.
@vlogwithdevesh9914
@vlogwithdevesh9914 4 жыл бұрын
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!!
@iksarpek
@iksarpek 4 жыл бұрын
Great quality
@meht8
@meht8 4 жыл бұрын
Awesome explanation!!!
@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
@dungeondj4418
@dungeondj4418 4 жыл бұрын
Great video, thank you!
@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()?
@subee128
@subee128 10 ай бұрын
Thanks
@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?
@abdurrezzakefe5308
@abdurrezzakefe5308 4 жыл бұрын
Very clean explanation, keep it up!
@abdurrezzakefe5308
@abdurrezzakefe5308 4 жыл бұрын
Also we can do it with just one stack.
@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.
@AutusDeletus98
@AutusDeletus98 4 жыл бұрын
will this work if you input 1 2 3? It seems like it will never get into the while loop.
@harshwardhanpatil361
@harshwardhanpatil361 3 жыл бұрын
What will be the time complexity.
@sharkdeng9253
@sharkdeng9253 3 жыл бұрын
Could you give a working code here. Since I still failed the test. Thanks!
@shubhamrawat7895
@shubhamrawat7895 4 жыл бұрын
Damn too good!
@sohammalakar1899
@sohammalakar1899 4 жыл бұрын
Doesn't the brute force algorithm fail for {3 ,1} ?
@KnapsackLabs
@KnapsackLabs 4 жыл бұрын
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?
@Arunkumar-pg8kx
@Arunkumar-pg8kx 3 жыл бұрын
Both the stacks will be empty and starts tracking rectangles from scratch
@trungnguyennguyentri1975
@trungnguyennguyentri1975 3 жыл бұрын
@@Arunkumar-pg8kx ohhhhhh I see
@prakharsahu7145
@prakharsahu7145 3 жыл бұрын
ye to sach hai ki bhagwan hai
Coding Interview Problem - Longest Consecutive Sequence
12:19
Knapsack
Рет қаралды 1,6 М.
Coding Interview Problem - Decode Ways
13:53
Knapsack
Рет қаралды 19 М.
Ice Cream or Surprise Trip Around the World?
00:31
Hungry FAM
Рет қаралды 22 МЛН
За кого болели?😂
00:18
МЯТНАЯ ФАНТА
Рет қаралды 3,2 МЛН
Hoodie gets wicked makeover! 😲
00:47
Justin Flom
Рет қаралды 138 МЛН
Coding Interview Problem - Maximal Rectangle
19:41
Knapsack
Рет қаралды 5 М.
L12. Largest Rectangle in Histogram | Stack and Queue Playlist
31:42
take U forward
Рет қаралды 44 М.
Coding Interview Problem: Largest Rectangle in a Histogram
16:18
Jackson Gabbard
Рет қаралды 309 М.
Largest rectangle in Histogram | Leetcode #84
27:43
Techdose
Рет қаралды 111 М.
Coding Interview Problem - Gas Station
12:44
Knapsack
Рет қаралды 22 М.
Largest rectangle in a histogram
6:15
2BitFun
Рет қаралды 5 М.
LARGEST RECTANGLE IN HISTOGRAM - Leetcode 84 - Python
17:20
NeetCode
Рет қаралды 247 М.
Premature Optimization
12:39
CodeAesthetic
Рет қаралды 835 М.
Largest Rectangle in Histogram - Leetcode 84 - Stacks (Python)
10:59
Coding Interview Problem - Word Break
20:08
Knapsack
Рет қаралды 23 М.
Ice Cream or Surprise Trip Around the World?
00:31
Hungry FAM
Рет қаралды 22 МЛН