Skip to content

Commit 48e3748

Browse files
committed
move zero atlast
1 parent 7bb885b commit 48e3748

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

geek_for_geeks/challenge/move_zero.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
def pushZerosToEnd(arr):
2+
count = 0
3+
n = len(arr)
4+
for i in range(n):
5+
if arr[i] != 0:
6+
arr[count] = arr[i]
7+
count += 1
8+
while count < n:
9+
arr[count] = 0
10+
count += 1
11+
return arr

0 commit comments

Comments
 (0)