Created
December 3, 2020 21:33
-
-
Save kingsamadesu/a2ed5eb65bdada0c990a4f607d7bf0eb to your computer and use it in GitHub Desktop.
283. Move Zeroes -with java- (leetcode.com)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Your runtime beats 100.00 % of java submissions. | |
*/ | |
class Solution { | |
public void moveZeroes(int[] nums) { | |
int j = 0; | |
for (int i = 0 ; i < nums.length-1 ; i++){ | |
if(nums[i]==0){ | |
if(nums[i+1]==0){ | |
j++; | |
}else{ | |
nums[i-j]=nums[i+1]; | |
nums[i+1] = 0; | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment