Best So Far
Imagine reading numbers from left to right and writing down the best value seen so far after each new number. Write a function running_max that, for each index i, takes the maximum of all elements from the start of the list through i. Return the list of these running maximums.
Примеры
Ввод
[1, 3, 2, 5, 4]Вывод
[1, 3, 3, 5, 5]Ввод
[5, 4, 3]Вывод
[5, 5, 5]Ввод
[1, 2, 3]Вывод
[1, 2, 3]Нужно реализовать
def running_max(nums: list[int]) -> list[int]:
Теги
arraylists
Connectez-vous pour voir l'historique des soumissions
Se connecterConnectez-vous pour utiliser le Mentor IA
Se connecterVisible tests
1
Input
[1,3,2,5,4]Expected
[1,3,3,5,5]2
Input
[5,4,3]Expected
[5,5,5]3
Input
[1,2,3]Expected
[1,2,3]4
Input
[]Expected
[]5
Input
[7]Expected
[7]6
Input
[-1,-2,0]Expected
[-1,-1,0]Focus radio
Paused · SomaFM · Fluid