LeetCode: Average Salary Excluding the Minimum and Maximum Salary
Question
Given an array of unique integers salary where salary[i] is the salary of the employee i.
Return the average salary of employees excluding the minimum and maximum salary.
Solution
def average(salary)
salary.delete(salary.min)
salary.delete(salary.max)
salary.reduce(0.0){ |sum, num| sum + num }.to_f / salary.size
end
Comments