第二十二天
LeetCode热题 100
移动零
283. 移动零 - 力扣(LeetCode)
思路
双指针
class Solution {
public:
void moveZeroes(vector<int>& nums) {
int slowIndex = 0;
for(int fastIndex = 0;fastIndex < nums.size();fastIndex++){
if(nums[fastIndex] != 0){
swap(nums[slowIndex],nums[fastIndex]);
slowIndex++;
}
}
}
};