Keep the Order
This unusual sort does not move elements around; it removes anything that breaks the order. Walk through sequence from left to right and keep a number only if it is not smaller than every number already kept. Return the non-decreasing list of surviving elements.
Примеры
Ввод
[4, 3, 5, 2, 1, 7]Вывод
[4, 5, 7]Ввод
[1, 2, 3, 4]Вывод
[1, 2, 3, 4]Ввод
[4, 5, 5, 2, 3]Вывод
[4, 5, 5]Нужно реализовать
def stalin_sort(sequence: list[int]) -> list[int]:
Теги
sorting
Συνδεθείτε για να δείτε το ιστορικό υποβολών
ΣύνδεσηΣυνδεθείτε για να χρησιμοποιήσετε τον AI Mentor
ΣύνδεσηTests12
Visible tests
Κρυφό τεστ 7
Κρυφό τεστ 8
Κρυφό τεστ 9
Κρυφό τεστ 10
Κρυφό τεστ 11
Κρυφό τεστ 12
They run when you press "Submit" — your whole solution is checked against them so you can't hard-code answers for the visible cases.
Focus radio
Paused · SomaFM · Fluid