Answers for "1491. Average Salary Excluding the Minimum and Maximum Salary leetcode solution in c++"

C++
0

1491. Average Salary Excluding the Minimum and Maximum Salary leetcode solution in c++

class Solution {
public:
    double average(vector<int>& salary) {
        double res;
        int n=salary.size(),sum=0;
        sort(salary.begin(),salary.end());
        for(int i=0;i<salary.size();i++)
        {
            sum+=salary[i];
        }
        res = sum - (salary[0] + salary[n-1]);
        res/=(n-2);
        return res;
    }
};
Posted by: Guest on March-01-2022

Code answers related to "1491. Average Salary Excluding the Minimum and Maximum Salary leetcode solution in c++"

Browse Popular Code Answers by Language