Range Edges
When you have a set of numbers, you often need to quickly find its lower and upper boundaries. Write a function min_max that takes a non-empty list lst and returns a list with two elements: the minimum number and the maximum number. If the list contains only one element, that value is both the minimum and the maximum.
Примеры
Ввод
[1, 2, 3, 4, 5]Вывод
[1, 5]Ввод
[2334454, 5]Вывод
[5, 2334454]Ввод
[1]Вывод
[1, 1]Нужно реализовать
def min_max(lst: list[int]) -> list[int]:
Теги
listsarraymath
Влез, за да видиш историята на решенията
ВходВлез, за да използваш ИИ ментора
ВходVisible tests
1
Input
[1,2,3,4,5]Expected
[1,5]2
Input
[2334454,5]Expected
[5,2334454]3
Input
[1]Expected
[1,1]4
Input
[-3,-2,-1]Expected
[-3,-1]5
Input
[7,7,7]Expected
[7,7]6
Input
[2,3,4,5,6]Expected
[2,6]Focus radio
Paused · SomaFM · Fluid