Smallest and Largest Four-Sum
Imagine five numbers where you must choose exactly four of them each time and add them together. The function mini_max_sum receives a list arr of five integers. Find the smallest and largest sums you can make this way, then return them as [min_sum, max_sum].
Примеры
Ввод
[1, 2, 3, 4, 5]Вывод
[10, 14]Ввод
[7, 69, 2, 221, 8974]Вывод
[299, 9271]Ввод
[1, 1, 1, 1, 1]Вывод
[4, 4]Нужно реализовать
def mini_max_sum(arr: list[int]) -> list[int]:
Теги
arraysortingmath
Conectează-te pentru a vedea istoricul soluțiilor trimise
Conectează-teConectează-te pentru a folosi Mentorul AI
Conectează-teVisible tests
1
Input
[1,2,3,4,5]Expected
[10,14]2
Input
[7,69,2,221,8974]Expected
[299,9271]3
Input
[1,1,1,1,1]Expected
[4,4]4
Input
[5,4,3,2,1]Expected
[10,14]5
Input
[100,200,300,400,500]Expected
[1000,1400]6
Input
[2,3,4,5,6]Expected
[14,18]Focus radio
Paused · SomaFM · Fluid