1 ms Java Solution


  • 0
    C
    public class Solution {
    public void moveZeroes(int[] nums) {
        int counter=0;
        for (int i=0;i<nums.length;i++){
            if(nums[i]==0){
                counter++;
                continue;
            }
            else{
                nums[i-counter]=nums[i];
                continue;
            }
        }
        for (int i=nums.length-counter;i<nums.length;i++){
            nums[i]=0;
        }
    }
    

    }


  • 0
    J

    continue in first not using...


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.