1 class Solution { 2 public: 3 void reOrderArray(vector<int> &array) { 4 deque<int> myque; 5 vector<int>::iterator iter = array.begin(); 6 for(;iter!=array.end();++iter){ 7 if(!((*iter)&1)){ 8 myque.push_back(*iter); 9 } 10 } 11 iter = array.end() - 1; 12 for(;iter>=array.begin();--iter){ 13 if((*iter)&1){ 14 myque.push_front(*iter); 15 } 16 } 17 vector<int> tmp(myque.begin(),myque.end()); 18 array.swap(tmp); 19 } 20 };
牛客提示有段错误,栈溢出,
在gcc编译下没问题;