개발이 취미인 주니어 기획자

[Sorting][JavaScript][LeetCode] #1491. Average Salary Excluding the Minimum and Maximum Salary 본문

문제 풀이/기본 구현

[Sorting][JavaScript][LeetCode] #1491. Average Salary Excluding the Minimum and Maximum Salary

큐 2023. 5. 2. 11:00
728x90
반응형

#Sorting  #EASY

 

Average Salary Excluding the Minimum and Maximum Salary - LeetCode

Can you solve this real interview question? Average Salary Excluding the Minimum and Maximum Salary - You are given an array of unique integers salary where salary[i] is the salary of the ith employee. Return the average salary of employees excluding the m

leetcode.com

 

🌷 문제 설명

✏️ LeetCode 연습문제: Average Salary Excluding the Minimum and Maximum Salary
You are given an array of unique integers salary where salary[i] is the salary of the ith employee.
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] <= 10^6
All the integers of salary are unique

입출력 예

nums result
[4000, 3000, 1000, 2000] 2500.00000
[1000, 2000, 3000] 2000.0000

 

🌷 내 코드

var average = function(salary) {
  salary.sort((a,b) => a-b)
  salary.pop()
  salary.shift()
  return salary.reduce((acc, curr) => acc + curr, 0) / salary.length
};

 

🌷 코멘트

사실 이런건 너무 별거 아니라서 블로그에는 안 올리려고 하는데 (블로그엔 안올려도 깃허브엔 1일 1커밋 하고 있읍니당)
99%는 귀하니까.. 기록..

블로그 내용에 문제가 있다면 댓글 혹은 아래로 연락주세요!

~대가리 꽃밭인 디지털 노마드가 꿈이예요~

🧚‍♀️ Gyumin Lee

📧 gyumin.q.lee@gmail.com

 

qminlee723 - Overview

noob. qminlee723 has 8 repositories available. Follow their code on GitHub.

github.com

728x90
반응형