Fill With the Larger End
Sometimes the answer depends only on the edge values of a list, while the middle does not matter. Write a function max_end3 that takes a list nums with exactly 3 numbers. Compare the first and last elements, choose the larger one, and return a list of three copies of that value.
Примеры
Ввод
[1, 2, 3]Вывод
[3, 3, 3]Ввод
[11, 5, 9]Вывод
[11, 11, 11]Ввод
[2, 11, 3]Вывод
[3, 3, 3]Нужно реализовать
def max_end3(nums: list[int]) -> list[int]:
Теги
listsarray
Logáil isteach chun stair na n-aighneachtaí a fheiceáil
Logáil isteachLogáil isteach chun an Meantóir IS a úsáid
Logáil isteachVisible tests
1
Input
[1,2,3]Expected
[3,3,3]2
Input
[11,5,9]Expected
[11,11,11]3
Input
[2,11,3]Expected
[3,3,3]4
Input
[5,2,5]Expected
[5,5,5]5
Input
[0,0,0]Expected
[0,0,0]6
Input
[11,9,5]Expected
[11,11,11]Focus radio
Paused · SomaFM · Fluid