Skip to content

Commit

Permalink
Create move_all.py
Browse files Browse the repository at this point in the history
Signed-off-by: Akash <[email protected]>
  • Loading branch information
Akash1437 committed Oct 17, 2022
1 parent 61bb047 commit c2c8348
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions move_all.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
def pushZerosToEnd(arr, n):
count = 0

for i in range(n):
if arr[i] != 0:
arr[count] = arr[i]
count+=1

while count < n:
arr[count] = 0
count += 1

arr = [1, 9, 8, 4, 0, 0, 2, 7, 0, 6, 0, 9]
n = len(arr)
pushZerosToEnd(arr, n)
print("Array after pushing all zeros to end of array:")
print(arr)

0 comments on commit c2c8348

Please sign in to comment.