mirror of
https://github.com/Kiritow/OJ-Problems-Source.git
synced 2024-03-22 13:11:29 +08:00
Create 1619.cpp
This commit is contained in:
parent
d4bba90c1b
commit
2248ac578d
14
LeetCode/1619.cpp
Normal file
14
LeetCode/1619.cpp
Normal 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);
|
||||
}
|
||||
};
|
Loading…
Reference in New Issue
Block a user