Move Zeroes

Easy · Arrays & Strings · about 10 minutes

Asked at Meta, Bloomberg, Amazon, Microsoft, Google, Apple, Rivian.

Shift every zero in nums to the back of the array. The non-zero values must stay in the order they started in. Work in place (no second array) and return nums.

Related guides