Leetcode 283 Solution
This article provides solution to leetcode question 283 (move-zeroes)
Access this page by simply typing in "lcs 283" in your browser address bar if you have bunnylol configured.
Leetcode Question Link
https://leetcode.com/problems/move-zeroes
Solution
class Solution {
public:
void moveZeroes(vector<int>& nums) {
int l = 0;
int r = 0;
while (r < nums.size())
{
if (nums[r] == 0)
r++;
else
swap(nums[l++], nums[r++]);
}
}
};