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
PostgreSQLv16

Hier verschijnt het resultaat van je code

Visible tests
1
Input
None
Expected0
2
Input
[]
Expected0
3
Input
[3]
Expected0
4
Input
[-6,-20,-1,-10,-12]
Expected-28
5
Input
[6,2,1,8,10]
Expected16
6
Input
[1,1,11,2,3]
Expected6
Focus radio
Paused · SomaFM · Fluid