Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution {
- public:
- void moveZeroes(vector<int>& nums) {
- int sz = nums.size();
- for (int i = sz - 2; i >= 0; --i)
- {
- if (!nums[i])
- {
- int t = i;
- while (t < sz - 1 && nums[t + 1])
- {
- nums[t + 1] += nums[t];
- nums[t] = nums[t + 1] - nums[t];
- nums[t + 1] -= nums[t];
- ++t;
- }
- }
- }
- return;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment