Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
enumerate with start parameter solution in Clear category for Replace with Biggest by Sim0000
from typing import Iterable
def replace_biggest(data: list[int]) -> Iterable[int]:
return [max(data[i:], default=-1) for i, _ in enumerate(data, 1)]
print("Example:")
print(list(replace_biggest([17, 18, 5, 4, 6, 1])))
assert list(replace_biggest([17, 18, 5, 4, 6, 1])) == [18, 6, 6, 6, 1, -1]
assert list(replace_biggest([1, 2, 3, 4, 5, 6])) == [6, 6, 6, 6, 6, -1]
assert list(replace_biggest([1, 1, 1])) == [1, 1, -1]
print("The mission is done! Click 'Check Solution' to earn rewards!")
Nov. 10, 2022