Advertisement
Guest User

Untitled

a guest
Apr 4th, 2020
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rust 0.38 KB | None | 0 0
  1. impl Solution {
  2.     pub fn move_zeroes(nums: &mut Vec<i32>) {
  3.         let mut i = 0;
  4.         let mut j = 0;
  5.         let n = nums.len();
  6.         while j < n {
  7.             nums[i] = nums[j];
  8.             j += 1;
  9.             if nums[i] != 0 {
  10.                 i += 1;
  11.             }
  12.         }
  13.         while i < n {
  14.             nums[i] = 0;
  15.             i += 1;
  16.         }
  17.     }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement