leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

1491.cpp (404B)


      1 class Solution {
      2   public:
      3     double average(vector<int> &salary) {
      4         int mini = *min_element(salary.begin(), salary.end());
      5         int maxi = *max_element(salary.begin(), salary.end());
      6         int sum = 0, count = 0;
      7         for (int i = 0; i < salary.size(); i++)
      8             if (salary[i] != mini && salary[i] != maxi) sum += salary[i], count++;
      9 
     10         return (double)sum / count;
     11     }
     12 };