Reverse a stack

i didnt une=derstood the concept please help me with this

Imagine you have a stack with elements 1, 2, 3, 4 (4 is at the top of the stack and 1 at the bottom of the stack). Now, what we do is we recursively pop the element from the stack and keep it in the helper stack(or the function call stack) and after the stack is empty we start pushing back the elements into the original stack in the order they were popped except that, here every new incoming element is not pushed into the stack until we encounter its bottom. Once we encounter the stack’s bottom, we put that element there and put back the rest of the elements of the stack as they were.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.