Logo
IconChallenge
Icon
IconProblem
IconSolutions
IconSubmissions

Move Zeroes

XPChallenge Points: 10
levelLevel: Easy

You are given an integer array nums.
Your task is to move all zeroes in the array to the end, while maintaining the relative order of all non-zero elements.

You must perform this operation in-place, meaning you cannot create a copy of the array.

Example 1:

Input: nums = [4, 0, 5, 0, 3, 12]

Output: [4, 5, 3, 12, 0, 0]

Example 2:

Input: nums = [1, 2, 0, 0, 5, 6]

Output: [1, 2, 5, 6, 0, 0]

to Continue
like
dislike

Accepted:

Submission:

IconReport an issue
Icon
IconCode
IconYou need toto run or submitYou need toto run or submit
IconTest Case
IconTest Result