Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Run-time complexity O(n)
- // Memory complexity O(1)
- void moveZeroes(vector<int>& nums) {
- int pos0 = 0;
- for (int i = 0; i < nums.size(); ++i) {
- if (nums[i] != 0) {
- swap(nums[i], nums[pos0++]);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement