Skip to content

Commit 37f28e3

Browse files
committedApr 16, 2020
Adding Simple Solution for Problem - 283 Move Zeroes
1 parent aa2d857 commit 37f28e3

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed
 

‎Move_Zeroes/SimpleSolution.py

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
##==================================
2+
## Leetcode
3+
## Student: Vandit Jyotindra Gajjar
4+
## Year: 2020
5+
## Problem: 283
6+
## Problem Name: Move Zeroes
7+
##===================================
8+
#Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements.
9+
#
10+
#Example:
11+
#
12+
#Input: [0,1,0,3,12]
13+
#Output: [1,3,12,0,0]
14+
class Solution:
15+
def moveZeroes(self, nums):
16+
zero = nums.count(0) #Count the number of zero in given array.
17+
for i in range(zero):
18+
nums.remove(0) #This will remove zero.
19+
nums.append(0) #This will append zero at the end of list.

0 commit comments

Comments
 (0)