class Solution {
public:
void moveZeroes(vector<int>& nums) {
int size = (int)(nums.size());
if( 0 == size || 1 == size )
return ;
int tmp = 0;
int i = 0;
int j = 0;
for(;i < size && j < size;++i)
{
if( 0 == nums[i] )
{
j = i;
while(0 == nums[j] && j < size)
++j;
if(j < size && i <= j && 0 != nums[j])
{
tmp = nums[i];
nums[i] = nums[j];
nums[j] = tmp;
}
}
}
}
};
【思考】
Minimize the total number of operations.
//to do【遗留】