Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@spreered
Created September 13, 2017 07:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spreered/c0a86026c82879f835eb4b91c64b595d to your computer and use it in GitHub Desktop.
Save spreered/c0a86026c82879f835eb4b91c64b595d to your computer and use it in GitHub Desktop.
def move_zeroes(nums)
countZero = 0
while nums.index(0)!=nil
pos = nums.index(0)
countZero += 1
nums.delete_at(pos)
end
nums.concat([0]*countZero)
end
def move_zeroes(nums)
a = nums.size
nums.delete(0)
while nums.size < a
nums << 0
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment