반응형
1. 문제를 똑바로 이해하고
2. 반환값이 int인지 double인지 확인하고
class Solution {
public:
double average(vector<int>& salary) {
sort(salary.begin(), salary.end());
double total = 0.0;
for(int i = 1;i<salary.size()-1;i++)
total +=salary[i];
return total/(salary.size()-2);
}
};
반응형
'IT > 알고리즘' 카테고리의 다른 글
28] Leetcode 1021. Remove Outermost Parentheses (0) | 2020.07.06 |
---|---|
27] Leetcode 1266. Minimum Time Visiting All Points (0) | 2020.07.06 |
25★] Leetcode 1496. Path Crossing (0) | 2020.07.05 |
24] Leetcode 1502. Can Make Arithmetic Progression From Sequence (0) | 2020.07.05 |
23] Leetcode 728. Self Dividing Numbers (0) | 2020.07.04 |
댓글