Stick Cutting Rounds
You have sticks of different lengths, and on each round every remaining stick is shortened by the length of the shortest stick. The shortest sticks disappear after that cut, while the others continue to the next round. The function cut_the_sticks receives a list of stick lengths arr. Return a list showing how many sticks were cut on each round until no sticks remain.
Примеры
Ввод
[5, 4, 4, 2, 2, 8]Вывод
[6, 4, 2, 1]Ввод
[1, 2, 3, 4, 3, 3, 2, 1]Вывод
[8, 6, 4, 1]Ввод
[1, 1, 1, 1]Вывод
[4]Нужно реализовать
def cut_the_sticks(arr: list[int]) -> list[int]:
Теги
arraysorting
Prihláste sa, aby ste videli históriu odoslaní
Prihlásiť saPrihláste sa, aby ste mohli používať AI mentora
Prihlásiť saVisible tests
1
Input
[5,4,4,2,2,8]Expected
[6,4,2,1]2
Input
[1,2,3,4,3,3,2,1]Expected
[8,6,4,1]3
Input
[1,1,1,1]Expected
[4]4
Input
[5]Expected
[1]5
Input
[3,3,2,1,3]Expected
[5,4,3]6
Input
[]Expected
[]Focus radio
Paused · SomaFM · Fluid