Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
max with default solution in Clear category for Replace with Biggest by m.kleinkranenbarg
from typing import Iterable
def replace_biggest(data: list[int]) -> Iterable[int]:
return [max(data[i + 1:], default=-1) for i in range(len(data))]
print("Example:")
print(list(replace_biggest([17, 18, 5, 4, 6, 1])))
# These "asserts" are used for self-checking
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!")
Feb. 19, 2023