Skip to content

Commit

Permalink
Merge pull request #593 from Zach-Houston/master
Browse files Browse the repository at this point in the history
Issue #570 - Move all zeroes to the end of an array
  • Loading branch information
Srikant Singh authored Oct 27, 2018
2 parents 8bb1331 + 0054831 commit 25d7dca
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Algorithms/Array/zeroMover.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Replace this with your own array.
arr = [1, 1, 0, 2, 3, 0, 1, 0]
zeroCounter = 0
newArr = []
for num in arr:
if num == 0:
zeroCounter+=1
else:
newArr.append(num)
for i in range(0, zeroCounter):
newArr.append(0)
print(newArr)

0 comments on commit 25d7dca

Please sign in to comment.