1491. Average Salary Excluding the Minimum and Maximum Salary Easy
1/**
2 * [1491] Average Salary Excluding the Minimum and Maximum Salary
3 *
4 * You are given an array of unique integers salary where salary[i] is the salary of the i^th employee.
5 * Return the average salary of employees excluding the minimum and maximum salary. Answers within 10^-5 of the actual answer will be accepted.
6 *
7 * Example 1:
8 *
9 * Input: salary = [4000,3000,1000,2000]
10 * Output: 2500.00000
11 * Explanation: Minimum salary and maximum salary are 1000 and 4000 respectively.
12 * Average salary excluding minimum and maximum salary is (2000+3000) / 2 = 2500
13 *
14 * Example 2:
15 *
16 * Input: salary = [1000,2000,3000]
17 * Output: 2000.00000
18 * Explanation: Minimum salary and maximum salary are 1000 and 3000 respectively.
19 * Average salary excluding minimum and maximum salary is (2000) / 1 = 2000
20 *
21 *
22 * Constraints:
23 *
24 * 3 <= salary.length <= 100
25 * 1000 <= salary[i] <= 10^6
26 * All the integers of salary are unique.
27 *
28 */
29pub struct Solution {}
30
31// problem: https://leetcode.com/problems/average-salary-excluding-the-minimum-and-maximum-salary/
32// discuss: https://leetcode.com/problems/average-salary-excluding-the-minimum-and-maximum-salary/discuss/?currentPage=1&orderBy=most_votes&query=
33
34// submission codes start here
35
36impl Solution {
37 pub fn average(salary: Vec<i32>) -> f64 {
38 0f64
39 }
40}
41
42// submission codes end
43
44#[cfg(test)]
45mod tests {
46 use super::*;
47
48 #[test]
49 fn test_1491() {
50 }
51}
52
Back
© 2025 bowen.ge All Rights Reserved.