Tap here to switch tabs
Problem
Submissions

Problem: Move Zeroes

Move Zeroes rearranges an integer array so every zero appears at the end while non-zero values keep their relative order. Modify the original array in place.

Statement

Given an integer array, nums, rearrange the elements such that all 0′s0's are moved to the end of the array, while the relative order of all non-zero elements is preserved.

Note: The operation must be performed in-place, without creating a copy of the array.

Constraints:

  • 1≤1 \leq nums.length ≤104\leq 10^4

  • −231≤-2^{31} \leq nums[i] ≤231−1\leq 2^{31} - 1

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Move Zeroes

Move Zeroes rearranges an integer array so every zero appears at the end while non-zero values keep their relative order. Modify the original array in place.

Statement

Given an integer array, nums, rearrange the elements such that all 0′s0's are moved to the end of the array, while the relative order of all non-zero elements is preserved.

Note: The operation must be performed in-place, without creating a copy of the array.

Constraints:

  • 1≤1 \leq nums.length ≤104\leq 10^4

  • −231≤-2^{31} \leq nums[i] ≤231−1\leq 2^{31} - 1