class Solution { public: /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param cows int整型vector * @return int整型vector */ vector<int> sortCows(vector<int>& cows) { // write code here int length = cows.size(); int left = 0, right = length - 1; while (left < right) { while (left < right && cows[left] == 0) left++; while (left < right && cows[right] == 1) right--; swap(cows[left], cows[right]); } return cows; } };