SHARE
TWEET

Untitled

bbescos Jan 28th, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     // Run-time complexity O(n)
  2.     // Memory complexity O(1)
  3.     void moveZeroes(vector<int>& nums) {
  4.         int pos0 = 0;
  5.         for (int i = 0; i < nums.size(); ++i) {
  6.             if (nums[i] != 0) {
  7.                 swap(nums[i], nums[pos0++]);
  8.             }
  9.         }
  10.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top