Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Move Zeros to Array End
00:00
5 left

Move Zeros to Array End

EasyPython

Problem

Given an integer array nums, move all 0 values to the end of the array while preserving the relative order of the non-zero elements. Modify the array in place and return the resulting array.

Constraints

  • 1 <= nums.length <= 10^5
  • -2^31 <= nums[i] <= 2^31 - 1
  • The relative order of non-zero elements must be preserved
  • Modify the array in place

Function Signature

def move_zeroes(nums):
Interviewer

Your question is Move Zeros to Array End. Start with the requirements in the Question tab.

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.
CodePython 3
You need to log in / sign up to run or submit.Ln 2
Run your code to see test output here.