空间换时间的o(n)思路
调整数组顺序使奇数位于偶数前面
http://www.nowcoder.com/questionTerminal/beb5aa231adc45b2a5dcc5b62c93f593
import java.util.*; public class Solution { public void reOrderArray(int [] array) { if (array == null || array.length < 1) { return; } ArrayList<Integer> list = new ArrayList<>(); for (int i = 0; i < array.length; i++) { if ((array[i] & 1) == 1) { list.add(array[i]); } } for (int i = 0; i < array.length; i++) { if ((array[i] & 1) == 0) { list.add(array[i]); } } for (int i = 0; i < array.length; i++) { array[i] = list.get(i); } } }