category-wise-problems

contains category wise problems(data structures, competitive) of popular platforms.

View the Project on GitHub mayankdutta/category-wise-problems

283. Move zeros

naive type implementation ```cpp class Solution { public: void moveZeroes(vector& nums) { vector ans; int count = 0; for (int i = 0; i < nums.size(); i++) { if (nums[i]) { ans.push_back(nums[i]); } else { count ++; } } while (count--) ans.push_back(0); swap(ans, nums); } }; ``` </details>
more concise ```cpp class Solution { public: void moveZeroes(vector& nums) { int j = 0; for (int i = 0; i < nums.size(); i++) { if (nums[i]) { nums[j++] = nums[i]; } } for (; j < nums.size(); j++) { nums[j] = 0; } } }; ``` </details>