Skip to content

Commit

Permalink
Issue rathoresrikant#570 - Move all zeroes to the end of an array
Browse files Browse the repository at this point in the history
  • Loading branch information
Zach-Houston committed Oct 27, 2018
1 parent 9e0aef6 commit 0054831
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 0054831

Please sign in to comment.