Skip to content

Commit 97206ac

Browse files
committed
Add solution #1491
1 parent e9992a4 commit 97206ac

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@
172172
1480|[Running Sum of 1d Array](./1480-running-sum-of-1d-array.js)|Easy|
173173
1481|[Least Number of Unique Integers after K Removals](./1481-least-number-of-unique-integers-after-k-removals.js)|Medium|
174174
1486|[XOR Operation in an Array](./1486-xor-operation-in-an-array.js)|Easy|
175+
1491|[Average Salary Excluding the Minimum and Maximum Salary](./1491-average-salary-excluding-the-minimum-and-maximum-salary.js)|Easy|
175176
1492|[The kth Factor of n](./1492-the-kth-factor-of-n.js)|Medium|
176177
1496|[Path Crossing](./1496-path-crossing.js)|Easy|
177178
1502|[Can Make Arithmetic Progression From Sequence](./1502-can-make-arithmetic-progression-from-sequence.js)|Easy|
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* 1491. Average Salary Excluding the Minimum and Maximum Salary
3+
* https://leetcode.com/problems/average-salary-excluding-the-minimum-and-maximum-salary/
4+
* Difficulty: Easy
5+
*
6+
* Given an array of unique integers salary where salary[i] is the salary of the employee i.
7+
*
8+
* Return the average salary of employees excluding the minimum and maximum salary.
9+
*/
10+
11+
/**
12+
* @param {number[]} salary
13+
* @return {number}
14+
*/
15+
var average = function(salary) {
16+
salary.sort((a, b) => a - b);
17+
salary.shift();
18+
salary.pop();
19+
20+
return salary.reduce((total, n) => total + n, 0) / salary.length;
21+
};

0 commit comments

Comments
 (0)