From 00548310ddffcc98b062ead20fa88bdd6bfe02a2 Mon Sep 17 00:00:00 2001 From: Zach-Houston Date: Sat, 27 Oct 2018 15:34:55 -0400 Subject: [PATCH] Issue #570 - Move all zeroes to the end of an array --- Algorithms/Array/zeroMover.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 Algorithms/Array/zeroMover.py diff --git a/Algorithms/Array/zeroMover.py b/Algorithms/Array/zeroMover.py new file mode 100644 index 000000000..84c8a4e80 --- /dev/null +++ b/Algorithms/Array/zeroMover.py @@ -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)