Легко Решено: 0 Процент решений: 0%

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.

Ограничения

0 ≤ length ≤ 100,000

Примеры

Пример 1
Ввод:
numbers = [0, 1, 0, 3, 12]

Ожидаемый вывод:
expected = [1, 3, 12, 0, 0]
Ввод:
std::vector<long long> numbers = {0, 1, 0, 3, 12};

Ожидаемый вывод:
std::vector<long long> expected = {1, 3, 12, 0, 0};
Ввод:
long[] numbers = new long[] {0, 1, 0, 3, 12};

Ожидаемый вывод:
long[] expected = new long[] {1, 3, 12, 0, 0};

Пояснение

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

Пример 2
Ввод:
numbers = [0, 0]

Ожидаемый вывод:
expected = [0, 0]
Ввод:
std::vector<long long> numbers = {0, 0};

Ожидаемый вывод:
std::vector<long long> expected = {0, 0};
Ввод:
long[] numbers = new long[] {0, 0};

Ожидаемый вывод:
long[] expected = new long[] {0, 0};

Пояснение

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

Ссылки

Это задание адаптировано для CodeUtility. Следуйте условию и ограничениям выше.

Учитесь у других

Решения сообщества

Пока нет опубликованных решений. Решите задание, чтобы поделиться первым.