SHARE
TWEET

Untitled

a guest Dec 7th, 2019 105 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Runtime: 0 ms, faster than 100.00% of Java online submissions for Move Zeroes.
  2. // Memory Usage: 37.1 MB, less than 100.00% of Java online submissions for Move Zeroes.
  3. class Solution {
  4.     public void moveZeroes(int[] nums) {
  5.         int i = 0;
  6.         for(int num: nums){
  7.             if(num != 0){
  8.                 if (nums[i] != num) nums[i] = num;
  9.                 i++;
  10.             }
  11.         }
  12.         while(i < nums.length){
  13.             nums[i] = 0;
  14.             i++;
  15.         }
  16.     }
  17. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top