Zeroes to the End
Sometimes zeroes get in the way of the useful values in a list, but you still need to keep them. Given nums, return a list where all non-zero elements keep their original relative order. Move all zeroes to the end. Do not reorder the other elements among themselves.
Примеры
Ввод
[0, 1, 0, 3, 12]Вывод
[1, 3, 12, 0, 0]Ввод
[0]Вывод
[0]Ввод
[1, 2, 3]Вывод
[1, 2, 3]Нужно реализовать
def move_zeroes(nums):
Теги
arraytwo-pointers
Log ind for at se indsendelseshistorik
Log indLog ind for at bruge AI-mentor
Log indVisible tests
1
Input
[0,1,0,3,12]Expected
[1,3,12,0,0]2
Input
[0]Expected
[0]3
Input
[1,2,3]Expected
[1,2,3]4
Input
[0,0,1]Expected
[1,0,0]5
Input
[4,0,5,0,0,6]Expected
[4,5,6,0,0,0]6
Input
[1,2,1,4,13]Expected
[1,2,1,4,13]Focus radio
Paused · SomaFM · Fluid