求一列数除了最大最小值之后的平均值,水题
1 #1491
2 #Runtime: 21 ms (Beats 35.34%)
3 #Memory: 13.4 MB (Beats 73.89%)
4
5 class Solution(object):
6 def average(self, salary):
7 """
8 :type salary: List[int]
9 :rtype: float
10 """
11 ma = 0
12 mi = 1000001
13 s = 0
14 for i in salary:
15 if i < mi:
16 mi = i
17 if i > ma:
18 ma = i
19 s += i
20 return (s - mi - ma) / (len(salary) - 2.0)