Facile 0 résolus 0 % de réussite

Move Zeroes

Move every zero to the end while keeping the other order.

Return the list with all zeros moved to the end. The non-zero values keep their relative order.

Implement move_zeroes(numbers).

Input

numbers: The list of integers.

Output

Return the rearranged list.

Contraintes

0 ≤ length ≤ 100,000

Exemples

Exemple 1
Entrée :
numbers = [0, 1, 0, 3, 12]

Sortie attendue :
expected = [1, 3, 12, 0, 0]
Entrée :
std::vector<long long> numbers = {0, 1, 0, 3, 12};

Sortie attendue :
std::vector<long long> expected = {1, 3, 12, 0, 0};
Entrée :
long[] numbers = new long[] {0, 1, 0, 3, 12};

Sortie attendue :
long[] expected = new long[] {1, 3, 12, 0, 0};

Explication

1, 3, 12 keep their order and the two zeros go last: [1, 3, 12, 0, 0].

Exemple 2
Entrée :
numbers = [0, 0]

Sortie attendue :
expected = [0, 0]
Entrée :
std::vector<long long> numbers = {0, 0};

Sortie attendue :
std::vector<long long> expected = {0, 0};
Entrée :
long[] numbers = new long[] {0, 0};

Sortie attendue :
long[] expected = new long[] {0, 0};

Explication

Only zeros: the list stays [0, 0].

Références

Ce défi a été adapté pour CodeUtility. Suivez l'énoncé et les contraintes ci-dessus.

Apprenez des autres

Solutions de la communauté

Aucune solution publiée pour l'instant. Résolvez ce défi pour partager la première.