4-Line code solution in C#


  • 0
    L
    public void MoveZeroes(int[] nums) {
        for(int i = 0, j = 1; i < nums.Length && j < nums.Length; )
            if(nums[i] != 0) { i++; j++; }
            else if(nums[j] == 0) j++;
            else nums[i] = nums[i] ^ nums[j] ^ (nums[j] = nums[i]);
    }

Log in to reply
 

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