Invert a stack, without using extra data structures?
Posted
by vks
on Stack Overflow
See other posts from Stack Overflow
or by vks
Published on 2009-07-02T07:06:16Z
Indexed on
2010/03/31
2:43 UTC
Read the original article
Hit count: 516
How would you invert a stack, without using extra data structures, like a second, or temporary, stack. Thus no stack1-stack2 or stack-queue-stack implementation in the answer. You just have access to push/pop feature of a standard stack.
I think there is way to do it by keeping a global counter and using pointer manipulation. If I solve it myself, I will post it. If someone else figures it out, please post your solution.
© Stack Overflow or respective owner