class Solution {
public:
void moveZeroes(vector<int>& nums) {
if(nums.empty()) return;
int n=nums.size();
int idx=n-1;
while(idx>=0&&nums[idx]==0) idx--;
for(int i=0;i<idx;i++)
{
while(nums[i]==0)
{
for(int j=i;j<idx;j++)
swap(nums[j],nums[j+1]);
idx--;
}
}
return;
}
};
标签:Leetcode283,idx,nums,int,vector,移动
From: https://www.cnblogs.com/tangxibomb/p/17555579.html