代码 class Solution: def average(self, salary: List[int]) -> float: minsalary = 1000000 maxsalary = 0 avg = 0 for i in salary: avg += i minsalary = min(minsalary, i) maxsalary = max(maxsalary, i) return (avg - minsalary - maxsalary) / (len(salary) - 2) 分类: LeetCode ...
具体看code。 Java Solution: Runtime: 0 ms, faster than 100.00% Memory Usage: 37.3 MB, less than 51.17% 完成日期:9/7/2020 关键点:sum - min - max classSolution {publicdoubleaverage(int[] salary) {doublemin = salary[0];doublemax = salary[0];doublesum = 0;for(ints : salary) { mi...
1491. Average Salary Excluding the Minimum and Maximum Salary solution #1: code solution #2: code 注意: 1. 去除最大最小值之后的平均值; 2. 数组元素是unique的; 3. 返回值类型是double的; 参考 1. leetcode_1491. Average Salary Excluding the Minimum and Maximum Salary...
13. but I have a question, is this really a O(n) solution? Yes, it is. according to leetcode, every element is processed exactly twice(which is added and removed from deque) and besides, this solution must be better than solutions using priority queue, since we can build heap in O(...
Given an array of unique integerssalarywheresalary[i]is the salary of the employeei. Return the average salary of employees excluding the minimum and maximum salary. Example 1: Input: salary = [4000,3000,1000,2000] Output: 2500.00000
leetcode_easy_array 1491. Average Salary Excluding the Minimum and Maximum Salary solution #1: code solution #2: code 注意: 1. 去除最大最小值之后的平均值; 2. 数组元素是unique的; 3. 返回值类型是double的; 参考 1.leetcode_1491. Average Salary Excluding the Minimum and Maximum Salary; ...