Notice
Recent Posts
Recent Comments
- Today
- Total
01-11 01:45
Tags
- ๋ฐฑ์๋
- CS
- ๋ฐ์ดํฐ๋ฒ ์ด์ค
- ๊ทธ๋ฆฌ๋
- ์๋ฐ
- PS
- pytorch
- leetcode
- ๊ตฌํ
- tree
- ํ๋ก๊ทธ๋๋จธ์ค
- spring
- ์กธ์ ์ํ
- OOP
- ๋ค์ต์คํธ๋ผ
- array
- dp
- java
- ๋ฌธ๋ฒ
- Graph
- ๋ฐฑ์ค
- ์๋ฃ๊ตฌ์กฐ
- ์์์ ๋ ฌ
- BFS
- ์๋ฐ์์ ์
- ๋ฒจ๋งํฌ๋
- database
- ์ธํด
- MST
- Algorithm
Link
Partially Committed
[LEETCODE] 1491. Average Salary Excluding the Minimum and Maximum Salary ๋ณธ๋ฌธ
๐ฅ Algorithm || ๋ฌธ์ ํ์ด/PS
[LEETCODE] 1491. Average Salary Excluding the Minimum and Maximum Salary
WonderJay 2022. 10. 9. 15:36728x90
๋ฐ์ํ
SMALL
TITLE : 1491.Average Salary Excluding the Minimum and Maximum Salary
Description : You are given an array ofuniqueintegerssalarywheresalary[i]is the salary of theithemployee.
Return the average salary of employees excluding the minimum and maximum salary. Answers within 10-5 of the actual answer will be accepted.
- 3 <= salary.length <= 100
- 1000 <= salary[i] <= 106
- All the integers of salary are unique.
๋จ์ํ๊ฒ vector ์์ ์ต๋, ์ต์ ์์๋ฅผ ์ ์ธํ๊ณ ํ๊ท ์ ์ฐ์ถํด์ ๋ฆฌํดํ๋ ๋ฉ์๋๋ฅผ ๊ตฌํํ๋ฉด ๋๋ค.
[C++]
class Solution {
public:
double average(vector<int>& salary) {
double maxi = *max_element(salary.begin(), salary.end());
double mini = *min_element(salary.begin(), salary.end());
double ans = 0.0;
for (int i = 0; i < salary.size(); i++) {
ans += salary[i];
}
ans -= (maxi + mini);
ans /= (salary.size() - 2);
return ans;
}
};
728x90
๋ฐ์ํ
LIST
'๐ฅ Algorithm || ๋ฌธ์ ํ์ด > PS' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[LEETCODE] 1281. Subtract the Product and Sum of Digits of an Integer (0) | 2022.10.10 |
---|---|
[LEETCODE] 191.Number of 1 Bits (0) | 2022.10.10 |
[LEETCODE] 1523. Count Odd Numbers in an Interval Range (0) | 2022.10.09 |
[CH01] ํฌํฌ์ธํฐ (0) | 2022.09.12 |
[CH01] ๊ตฌ๊ฐํฉ (0) | 2022.09.09 |
Comments