Zeroes to the Back

Lists sometimes contain "empty-looking" values that you want to move out of the way without losing the order of important data. The function move_zeroes receives a list nums and moves all zeroes to the end. Keep all non-zero numbers in their original relative order and return a new list.

Примеры

Ввод
[0, 1, 0, 3, 12]
Вывод
[1, 3, 12, 0, 0]
Ввод
[0, 0, 1]
Вывод
[1, 0, 0]
Ввод
[1, 2, 3]
Вывод
[1, 2, 3]

Нужно реализовать

def move_zeroes(nums: list[int]) -> list[int]:

Теги

arraytwo-pointers
PostgreSQLv16

Εδώ θα εμφανιστεί το αποτέλεσμα εκτέλεσης του κώδικα

Visible tests
1
Input
[0,1,0,3,12]
Expected[1,3,12,0,0]
2
Input
[0,0,1]
Expected[1,0,0]
3
Input
[1,2,3]
Expected[1,2,3]
4
Input
[0,0,0]
Expected[0,0,0]
5
Input
[]
Expected[]
6
Input
[12,3,0,1,0]
Expected[12,3,1,0,0]
Focus radio
Paused · SomaFM · Fluid