Sum Without the Extremes
Sometimes a total is calculated after removing one highest and one lowest value so they do not distort the result. Write sum_array, which takes arr and returns the sum of its elements after excluding one minimum and one maximum. If arr is None, empty, or has only one element, return 0.
Примеры
Ввод
NoneВывод
0Ввод
[]Вывод
0Ввод
[3]Вывод
0Нужно реализовать
def sum_array(arr) -> int:
Теги
arraymath
Συνδεθείτε για να δείτε το ιστορικό υποβολών
ΣύνδεσηΣυνδεθείτε για να χρησιμοποιήσετε τον AI Mentor
ΣύνδεσηVisible tests
1
Input
NoneExpected
02
Input
[]Expected
03
Input
[3]Expected
04
Input
[-6,-20,-1,-10,-12]Expected
-285
Input
[6,2,1,8,10]Expected
166
Input
[1,1,11,2,3]Expected
6Focus radio
Paused · SomaFM · Fluid