1491-Average-Salary-Excluding-the-Minimum-and-Maximum-Salary
Question
You are given an array of unique integers salary
where salary[i]
is the salary of the ith
employee.
Return the average salary of employees excluding the minimum and maximum salary. Answers within 10-5
of the actual answer will be accepted.
Solution
遍历相加总量并记录最小值和最大值。
减去最大值及最大值,然后返回平均数即可。
We traverse through the values, add them together and record the minimum and maximum values.
Next we subtract the maximum value and the minimum value from the sum, and then return the average value.
Code
1 | class Solution { |
1491-Average-Salary-Excluding-the-Minimum-and-Maximum-Salary
https://xuanhe95.github.io/2023/04/30/1491-Average-Salary-Excluding-the-Minimum-and-Maximum-Salary/