将start<end提到外面来,可以免去比较这一操作
class Solution {
public:
void reOrderArray(vector<int> &array) {
int start=0;
int end=array.size()-1;
if(array.size()){
while(array[start]%2)start++;
while(!(array[end]%2))end--;
}
while(start<end){
swap(array[start],array[end]);
while(array[start]%2)start++;
while(!(array[end]%2))end--;
}
}
};