easy

Move Zeroes

Given an integer array, move all zeros to the end while preserving the relative order of the non-zero elements. Do it in place without allocating a second array.

Constraints
  • 1 ≤ n ≤ 10^4
  • -2^31 ≤ nums[i] ≤ 2^31 - 1
Examples
in: nums = [0,1,0,3,12]
out: [1,3,12,0,0]

Code it yourself

Solve in
Test execution is not yet available for this exercise.Practice journal →Draft saved in this browser.
Hints:
Which approach applies?

Choose an approach to check your pattern recognition, or reveal the discussion when you need help.