[筆記] Leetcode - 1491. Average Salary Excluding the Minimum and Maximum Salary Posted on 2023-05-01 Edited on 2023-05-02 Views: Symbols count in article: 750 Reading time ≈ 1 mins. https://leetcode.com/problems/average-salary-excluding-the-minimum-and-maximum-salary/ 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. 1234class Solution: def average(self, salary: List[int]) -> float: salary.sort() return sum(salary[1:-1]) / (len(salary) - 2) 1234def average(self, salary: List[int]) -> float: salary.remove(min(salary)) salary.remove(max(salary)) return sum(salary) / len(salary) 12def average(self, salary: List[int]) -> float: return (sum(salary) - min(salary) - max(salary)) / (len(salary) - 2) 12345def average(self, salary: List[int]) -> float: salary.sort() salary.pop(0) salary.pop() return sum(salary) / len(salary)