Assuming that you only have push, pop, peek and IsEmpty operations you need two loops, and an intermediate stack:
In the first loop, you pop each item off the stack, and push it onto the temporary stack.
In the second loop, you pop each item off the temporary stack and push it onto both the original stack and the output stack.
&
If you can traverse the start from the bottom, then it isn't a stack copy operation, it's just a memory copy job.
Comments
Leave a comment