- Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy path_1491.java
23 lines (22 loc) · 715 Bytes
/
_1491.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
packagecom.fishercoder.solutions.secondthousand;
publicclass_1491 {
publicstaticclassSolution1 {
publicdoubleaverage(int[] salary) {
intmax = salary[0];
intmin = salary[0];
for (inti = 1; i < salary.length; i++) {
max = Math.max(max, salary[i]);
min = Math.min(min, salary[i]);
}
longtotal = 0;
intcount = 0;
for (inti = 0; i < salary.length; i++) {
if (salary[i] != max && salary[i] != min) {
total += salary[i];
count++;
}
}
return (double) total / count;
}
}
}