mirror of
https://github.com/Kiritow/OJ-Problems-Source.git
synced 2024-03-22 13:11:29 +08:00
15 lines
342 B
C++
15 lines
342 B
C++
class Solution {
|
|
public:
|
|
double trimMean(vector<int>& arr) {
|
|
int n = arr.size();
|
|
int toRemove = n / 20;
|
|
sort(arr.begin(), arr.end());
|
|
|
|
int sum = 0;
|
|
for (int i = toRemove; i < n - toRemove; i++) {
|
|
sum += arr[i];
|
|
}
|
|
return (double)sum / (n - toRemove - toRemove);
|
|
}
|
|
};
|