Create 1619.cpp

master
Kirigaya Kazuto 2022-09-14 20:50:14 +08:00 committed by GitHub
parent d4bba90c1b
commit 2248ac578d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 0 deletions

14
LeetCode/1619.cpp Normal file
View File

@ -0,0 +1,14 @@
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);
}
};