javasortingstack

sorting a stack with the help of other 2 temp stack


Need a help on sorting stack. Need to sort a stack of integer with the help of other 2 temp stacks, but the condition is in any point of time, we can not put bigger integer on top of small integer.

Without the condition I can solve, but not able do it with the condition.


Solution

  • That is Tower of Hanoi. Just look for that and you will find a lot of solutions.