My 0ms Java solution


  • 0
    L
    public class Solution {
        public void moveZeroes(int[] nums) {
            int j = 0;
            int tmp = 0;
            for (int i=0;i<nums.length;i++){
                if (nums[i] !=0) {
                    tmp = nums[i];
                    nums[i] = nums[j];
                    nums[j] = tmp;
                    j++;                
                }
            }
        }
    }
    

Log in to reply
 

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