Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Move Zeros to the End of Array

EasyPython00:00
Practice interviewer
In session
5 left
00:00

Your question is Move Zeros to the End of Array. Start with the requirements on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

Given an array of integers nums, move all zeros to the end of the array while maintaining the relative order of non-zero elements. Modify the array in place, and do not return anything. The order of non-zero elements must remain unchanged.

Constraints

  • 1 <= nums.length <= 10^4
  • -10^9 <= nums[i] <= 10^9

Function Signature

def move_zeroes(nums):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output