In this we are going to see a program on how to Move all Zeroes to end of Array in Python Programming Language.
# The solution should maintain the relative order of items in the array and should not use constant space.
def move_zeros(lst):
for i in range(len(lst)):
if lst[i] == 0:
lst.remove(lst[i])
lst.append(0)
return lst
print(move_zeros([0, 1, 0, 3, 12, 0, 0 , 2, 4, 5]))
# Coded By DHIRAJ SHELKE
#ENJOY CODING
Post a Comment
FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP