我自己用两端队列搞的: 求最高效的解法?
public class Test{
public static void main(String[] args) {
int[] a = new int[]{43,14,6,9,3,27,38,19,5};
Arrays.sort(a);
Deque al = new ArrayDeque();
for (int e : a) {
al.addFirst(e);
}
do {
System.out.println(
al.pollFirst());
if(!al.isEmpty())System.out.println(al.pollLast());
} while (al.size() > 0);
}
}