C# very simple solution


  • 0
    D
    public class Solution {
        public void MoveZeroes(int[] nums) {
            int count=0,k=0;
            for(int i=0;i<nums.Length;i++)
            {
                if(nums[i] != 0)
                {
                    nums[k]=nums[i];
                    k++;
                }
            }
            for(int j=k;j<nums.Length;j++)
            nums[j]=0;
        }
    }
    

Log in to reply
 

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