leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

0283.cpp (253B)


      1 class Solution {
      2   public:
      3     void moveZeroes(vector<int> &nums) {
      4         int j = 0;
      5         for (int i = 0; i < nums.size(); i++)
      6             if (nums[i] != 0) nums[j++] = nums[i];
      7 
      8         while (j < nums.size())
      9             nums[j++] = 0;
     10     }
     11 };