LeetCode(283) Move Zeroes

it2022-07-03  93

class Solution { public: void moveZeroes(vector<int>& nums) { int len=nums.size(); int start=0; for(int i=0;i<len;++i) { if(nums[i] == 0) continue; else nums[start++]=nums[i]; } while(start<len) { nums[start++]=0; } } };

这种快速交换的思想!

转载于:https://www.cnblogs.com/yanqi110/p/4964546.html


最新回复(0)