标签:
1 class Solution { 2 public Stack<Integer> sortStack(Stack<Integer> s1) { 3 Stack<Integer> s2 = new Stack<Integer>(); 4 while(!s1.isEmpty()) { 5 int temp = s1.pop(); 6 while(!s2.isEmpty() && s2.peek() > temp) { 7 s1.push(s2.pop()); 8 } 9 s2.push(temp); 10 } 11 return s2; 12 } 13 }
标签:
原文地址:http://www.cnblogs.com/diyishao/p/4300567.html