brief solution with Java


  • 0
    public class Solution {
        public  void moveZeroes(int[] nums) {
            int y=0;
            int temp=0;
            int len = nums.length;
            for (int x=0;x<len;x++){
                if (nums[x]!=0){
                    temp=nums[y];
                    nums[y]=nums[x];
                    nums[x]=temp;
                    y++;
                }
            }
        }
    }
    

Log in to reply
 

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