Skip to content

Instantly share code, notes, and snippets.

@kingsamadesu
Created December 3, 2020 21:08
Show Gist options
  • Save kingsamadesu/c9c69b138b803886d5f4bb6836027150 to your computer and use it in GitHub Desktop.
Save kingsamadesu/c9c69b138b803886d5f4bb6836027150 to your computer and use it in GitHub Desktop.
283. Move Zeroes -with java- (leetcode.com).
/*
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