Interview Question: N Stacks

  Рет қаралды 32,612

Byte by Byte

Byte by Byte

Күн бұрын

Пікірлер: 73
@swatipatil4727
@swatipatil4727 3 жыл бұрын
Honestly, the best explanation to this problem that i could found on the internet! More power to you!! :)
@vivianzhao1513
@vivianzhao1513 8 жыл бұрын
Your explanation is pretty intuitive cause I kind of get lost when going through the code in geeksforgeesk
@ByteByByte
@ByteByByte 8 жыл бұрын
I'm glad it was helpful!
@tanayasharma7776
@tanayasharma7776 2 жыл бұрын
glad i looked up for this , i could not understand this even after reading articles and watching some other explanations, the way you explained it with examples helped a lot .
@chandandwivedi2362
@chandandwivedi2362 4 жыл бұрын
I am your Huge fan. What I like most about you and your channel is that this is the place where I not only get the Solution of the problem but also idea about how to think and approach the problem. Thanks a Lot!! Keep the good work.
@Aditrash-n5j
@Aditrash-n5j Жыл бұрын
Brilliant Explanation !!! (Btw, which IDE you are using )
@sathanand
@sathanand 6 жыл бұрын
Summary: k + 1 linkedlists (or stacks) k linkedlists' head elements are in the top[] array. 1 - linkedlist of free elements. "free' holds the head of this list. next[] array has next pointers for each element in the above lists. push --> pop from the 'free' list and make it head of one of k lists. pop --> pop from the given list (one of the k) and make it head of 'free' list.
@ramubavireddi
@ramubavireddi 3 жыл бұрын
Thanks Anand. I think it is the simplest and straightforward summary/ steps of the solution.
@mandar.vaidya
@mandar.vaidya 4 жыл бұрын
This is the best , I did look at many places but glab found you . My best wishes with you .
@9awan
@9awan 3 жыл бұрын
This is a very informative video, Sam.
@PMPhotographyVideography
@PMPhotographyVideography 7 жыл бұрын
Good job man....you explained an "unreasonable" problem so well
@ByteByByte
@ByteByByte 7 жыл бұрын
haha thanks! it is a hell of a problem for sure
@ayushmishra3388
@ayushmishra3388 4 жыл бұрын
This problem should be titled as "STACKS ABSURDITY!".
@itzeltravels
@itzeltravels 8 жыл бұрын
Thank you so much for explaining these questions so well, I've been looking for videos that explain interview questions, and your explanations are the most understandable by far. Thanks again for doing this, it really helps!
@ByteByByte
@ByteByByte 8 жыл бұрын
You're very welcome! Thanks for the kind words :)
@cschandragiri
@cschandragiri 6 жыл бұрын
My brain started popping out, why would someone ask this question in an interview! You won't get it unless you have seen this solution before.
@ByteByByte
@ByteByByte 6 жыл бұрын
That's definitely not true
@JaiSinghKav
@JaiSinghKav 6 жыл бұрын
@ 14:52 shouldn't the stack data be 7 instead of 2?
@徐瑞斌-i8o
@徐瑞斌-i8o 5 жыл бұрын
It's easier to explain by just saying "using N+1 linked lists, for N stacks and one free list, all in linked list form. In detail we implement the link by an index array rather than a pointer. Finally, those N+1 linked list can reuse a same "link" array, though they should keep their own head. And use index -1 to stand for a null-pointer. The free list can in fact implemented as a stack, thus we have N+1 stacks."
@tanzeelrana7348
@tanzeelrana7348 4 жыл бұрын
why can't we use double linked lists ?
@karishmajain6980
@karishmajain6980 4 жыл бұрын
if the nextAvailable is -1 that means that the array is full. In that case do we double the size of the array or we do something else?
@robsylvester272
@robsylvester272 6 жыл бұрын
This is hot codin' dude. Well done.
@ByteByByte
@ByteByByte 6 жыл бұрын
Haha thanks!
@aditisharma6980
@aditisharma6980 7 жыл бұрын
Very appropriate explaination. Thank you!
@sumeshpandit9359
@sumeshpandit9359 4 жыл бұрын
finally, got the trick of pushing and popping.
@udaysaiphanindra3138
@udaysaiphanindra3138 6 жыл бұрын
thank you for clear explanation sir.
@ByteByByte
@ByteByByte 6 жыл бұрын
you're welcome!
@yooos3
@yooos3 7 жыл бұрын
Brilliant video and excellent logic! Thanks a lot!
@ByteByByte
@ByteByByte 7 жыл бұрын
Thank you!
@LegitGamer2345
@LegitGamer2345 4 жыл бұрын
idk if you will see this but , if you can make a video on implementing n queue in an array , it would be really helpful , the code is very similar to this but I end up getting lost in it , if you make a video on it , I'm sure I would gain more insight on it.
@sameeragrawal92
@sameeragrawal92 7 жыл бұрын
That was best explanation, the problem is quite tricky. You helped me understand it (Y)
@ByteByByte
@ByteByByte 7 жыл бұрын
Thank you! Glad the video helped :)
@anwarsiddiqui8210
@anwarsiddiqui8210 7 жыл бұрын
At 25:07 do we explicitly need to throw the IndexOutOfBoundsException, coz operation at 27:52 could also throw the same exception...
@ByteByByte
@ByteByByte 7 жыл бұрын
You're right. I think it is better code this way, though, because it's much more clear when there is going to be an exception
@anwarsiddiqui8210
@anwarsiddiqui8210 7 жыл бұрын
I see, by the way very lucid explanation... #wayToGo
@siteshp
@siteshp 6 жыл бұрын
Thanks for explaning it so well. I loved every bit of it and sort of it had become intuitive in the middle. Keep up the good work
@ByteByByte
@ByteByByte 6 жыл бұрын
You're welceom!
@vasan65
@vasan65 8 жыл бұрын
Loved your way of explanation, I heard your push explanation and was able to figure out pop. Thank you so much.
@ByteByByte
@ByteByByte 8 жыл бұрын
Srinivas Jagadeesh so glad I could help!
@codeAsCoder
@codeAsCoder 3 жыл бұрын
Thank you sir 😀
@pawansaini4624
@pawansaini4624 5 жыл бұрын
Thanks sir, nice explanation
@vivekshaw2437
@vivekshaw2437 5 жыл бұрын
Thanks a lot. Brilliant Video.
@vishvaasvardaan
@vishvaasvardaan 6 жыл бұрын
Hi thanks! Really good explanation. But is this efficient?
@ByteByByte
@ByteByByte 6 жыл бұрын
In what way?
@ashishchaturvedi3710
@ashishchaturvedi3710 6 жыл бұрын
Great Work
@ByteByByte
@ByteByByte 6 жыл бұрын
thanks!
@harshmodi5666
@harshmodi5666 7 жыл бұрын
Amazing explanation. Very Simple, clear and effective. Thank you so much :)
@ByteByByte
@ByteByByte 7 жыл бұрын
Thanks!
@edwardhouser5318
@edwardhouser5318 6 жыл бұрын
what a about creating three stacks with one array? Reply
@ambika1107
@ambika1107 6 жыл бұрын
I am a QA from bay area looking for job. This question seem to be too much for .a QA and why would someone ask this. Its very confusing for me. I am looking at the video again and again by rewinding to understand better
@ByteByByte
@ByteByByte 6 жыл бұрын
What makes you think they would ask this of a QA? I don't know too much about QA interviews, but this is definitely reasonable for an SE
@edwardhouser5318
@edwardhouser5318 6 жыл бұрын
what a about creating three stack with one array?
@ByteByByte
@ByteByByte 6 жыл бұрын
You could do that, but you're limited to 3 stacks
@rahulbhati3079
@rahulbhati3079 4 жыл бұрын
Thanks sir
@RaviTejaVanjarapu
@RaviTejaVanjarapu 7 жыл бұрын
Awesome explaination !!
@ByteByByte
@ByteByByte 7 жыл бұрын
Thank you :)
@BardzoZueDziecko
@BardzoZueDziecko 3 жыл бұрын
How it's n stacks with a single array if you're using 3 arrays to implement it xD
@JEDIWJR
@JEDIWJR 7 жыл бұрын
Like your video. That helps a lot man.
@ByteByByte
@ByteByByte 7 жыл бұрын
thanks!
@aprofromuk
@aprofromuk 8 жыл бұрын
maybe it wud have been easier to understand if u named the nextIndex[] array to prevNextIndex[] array illustrating its use case clearly through the name :)
@ByteByByte
@ByteByByte 8 жыл бұрын
yeah that might help. prevNext* sounds totally contradictory though :P
@sankethb.k642
@sankethb.k642 5 жыл бұрын
Amazing!!!
@rohitashwanigam
@rohitashwanigam 5 жыл бұрын
Beautiful
@BrianFaure1
@BrianFaure1 7 жыл бұрын
Why would someone dislike this video? wtf
@ByteByByte
@ByteByByte 7 жыл бұрын
@wildglorypsn
@wildglorypsn 8 жыл бұрын
such a difficult and complex problem :/
@ByteByByte
@ByteByByte 8 жыл бұрын
I wouldn't necessarily expect this in an interview, but it's still good to push yourself :)
@siddharthsharma3679
@siddharthsharma3679 6 жыл бұрын
@wildglorypsn, just make sure you dont pop your brains out.
@cooldudeyanarp
@cooldudeyanarp 7 жыл бұрын
instead of typing the entire code u could have explained the solution on paper :(
@ByteByByte
@ByteByByte 7 жыл бұрын
I could, but I don't think it would be very easy to read. Would love a tablet to write on, though
@jss672006
@jss672006 6 жыл бұрын
You took 41 minutes to explain this and too much code if (top1 < top2 - 1) { top1++; arr[top1] = x; } OR top2--; arr[top2] = x; AND if (top1 >= 0 ) { int x = arr[top1]; top1--; return x;
@ByteByByte
@ByteByByte 6 жыл бұрын
I mean you would have failed your interview for not listening to the problem, but okay
Interview Question: Sort Stacks
17:10
Byte by Byte
Рет қаралды 20 М.
Interview Question: Three Sum
27:13
Byte by Byte
Рет қаралды 61 М.
小丑女COCO的审判。#天使 #小丑 #超人不会飞
00:53
超人不会飞
Рет қаралды 16 МЛН
黑天使被操控了#short #angel #clown
00:40
Super Beauty team
Рет қаралды 61 МЛН
Enceinte et en Bazard: Les Chroniques du Nettoyage ! 🚽✨
00:21
Two More French
Рет қаралды 42 МЛН
Interview Question: Find All Duplicates
18:51
Byte by Byte
Рет қаралды 41 М.
Dynamic Programming isn't too hard. You just don't know what it is.
22:31
DecodingIntuition
Рет қаралды 240 М.
one year of studying (it was a mistake)
12:51
Jeffrey Codes
Рет қаралды 206 М.
Rust vs C++
7:18
conaticus
Рет қаралды 105 М.
How to Remember Everything You Read
26:12
Justin Sung
Рет қаралды 3 МЛН
Interview Question: Max Stack
23:30
Byte by Byte
Рет қаралды 35 М.
Stack Data Structure | JavaScript
16:29
Traversy Media
Рет қаралды 99 М.
Interview Question: Palindromes
16:43
Byte by Byte
Рет қаралды 29 М.
Premature Optimization
12:39
CodeAesthetic
Рет қаралды 849 М.