Reverse a Stack using Recursion

preview_player
Показать описание
Reverse a Stack in O(1) space using Recursion.

The Notes that I taught in the video and the Working Code (if any) will be available on my Patreon page under the "Notes, Code And Support" tier.

------------------------------------------------------------------------------------------
Here are some of the gears that I use almost everyday:

PS: While having good gears help you perform efficiently, don’t get under the impression that they will make you successful without any hard work.
Рекомендации по теме
Комментарии
Автор

This IBH is amazing, we dont have to go through the entire recursion, just using base condition and n-1 iteration, and recursion takes care of the rest!!!! Damnnn, seriously recursion does work like magic! Thank you for such brilliant breakdown of recursion, no body teaches anything like these stuff! Kudos

sumitkeshav
Автор

I have gone through these questions and codes about 10 times but until now I have just mugged up the codes. This is the first time I know how recursion works and what's really happening. Thanks a lot for the amazing explanation.Looking forward to backtracking and graph playlist.I think people are eagerly waiting for these two playlists from you.

abhishekupadhyay
Автор

This is gold...nobody is teaching like this

AnkitKumar-ftyu
Автор

I did reverse stack using recursion without watching this video. it was somewhat like sort stack and array. previous video helped me to think in this side. Thanks Aditya Appreciate your effort. I wish I could contribute to petreon.

randomthoughts
Автор

The way you build up the logic for complex problems by first hitting at the head of the easier ones is just MIND-BLOWING! YOU LOOK LIKE A MAGICIAN TO

sankalparora
Автор

I was going through each video one by one and implementing it alongside..
the moment I listened to the problem, I was able to create the solution out of it, and it worked in the first go itself.
Reason - he teaches you how to think around the problem...not only the solution.
Thanks, @Aditya Verma..kudos to you!

jaisingh-lbfp
Автор

for the first time I could write my own recursion program :) Thanks a lot for the amazing work. Your teaching style remind me of friend who used to teach all in the early morning before exams.

swapnilraj
Автор

Sir vo Dp vale playlist mei kuch ques reh gaye the like LIS, substring vgrh k, toh unko plz add kr digiye. And thanks a lot bhaiya

sanidhyagupta
Автор

You are making our lives easy
I have watched many videos of recursion but did not understood the concept till I watched yours. Thanks for your support

Ramsiya
Автор

Man! The foundation you've built with the previous videos is so good that I didn't even have to watch this video before figuring out the solution!


//Method to insert the popped element at the beginning
const insert = (stack, element) =>{
// Base Condition
if(stack.length === 0){
stack.push(element);
return;
}

let top = stack.pop();
insert(stack, element);
stack.push(top);
}

// Method to reverse the stack
const reverse = (stack) => {
//Base Condition
if(stack.length === 1){
return;
}

let top = stack.pop();
reverse(stack);
insert(stack, top);
}

DroidHolicOfficial
Автор

Solved this question without seeing your video, that's the power of your teaching 🔥

techpowercoders
Автор

😭😭😭😭bhai aapki wajh se mai rcursion ke problem khud se solve kar paa rha hu aap god ho sach mai

akworld
Автор

thank you, i watched your previous videos from playlist and i was able to attempt this one without any difficulty, thanks a lot.

humanbean
Автор

Finally, At the middle of this video i myself found the base case for the reverse and insert function even after you forgot to mention that which you gave later in the video of course.
Thank you bhaiya for this recursion series. 🙏

AnkushKumar-mkns
Автор

Done myself within 10 mins, thanks a lot

simply_akhl
Автор

brother hats off to you, your content, your methods can't deny recursion works like magic !!!

somnathpandey
Автор

Bhaiya u explained recursion so well.
I got the core idea of solving problems using recursion just by watching this lecture.
Man you are a terrific teacher.
Thank you for this amazing content.

yatendraupadhyay
Автор

Did this on my own for the very first time . thanks brother .😁

avishkarrangari
Автор

Was able to solve it by my own, thank you sir , you are providing Gold.

ananysharma
Автор

solved the question without watching the video. You made the concept so clear in previous videos .Thanks a lot

deepkumbhare