sort(stack): sorted = new stack() while !stack.empty(): temp = stack.pop() while !sorted.empty() && sorted.peek() > temp: stack.push(sorted.pop()) sorted.push(temp) while !sorted.empty(): stack.push(sorted.pop())
No comments:
Post a Comment