直接模拟即可 :
class Solution {
public double average(int[] salary) {
double sum = 0;
double maxValue = Integer.MIN_VALUE, minValue = Integer.MAX_VALUE;
for (int num : salary) {
sum += num;
maxValue = Math.max(maxValue, num);
minValue = Math.min(minValue, num);
}
return (sum - maxValue - minValue) / (salary.length - 2);
}
}