Kotlinlearncs.online LogoJava
Return to List

Solve: Move Zeros to End

Created By: Justin Maier
/ Version: 2024.9.0

Write a function moveZerosToEnd that takes an array of ints and returns a new array with the same elements as the original, but all zeros are moved to the end while maintaining the order of the non-zero elements.

For example if the array is {0, 1, 0, 3, 12}, the returned array should be {1, 3, 12, 0, 0}.

Related Lessons

Stuck? You may find these lessons helpful: