标签:turn 数组 vector code 复杂度 solution http 时间复杂度 mic
进行一次快排即可
class Solution { public: vector<int> exchange(vector<int>& nums) { int le = 0; int ri = nums.size() - 1; while(le<ri){ while (le < ri&&nums[ri] % 2 == 0) ri--; while (le < ri&&nums[le] % 2 == 1) le++; if (le < ri) { int temp = nums[le]; nums[le] = nums[ri]; nums[ri] = temp; } } return nums; } };
标签:turn 数组 vector code 复杂度 solution http 时间复杂度 mic
原文地址:https://www.cnblogs.com/-citywall123/p/13583527.html