728x90

Problem
https://www.hackerrank.com/challenges/grading/problem?isFullScreen=true

Code
function gradingStudents(grades) {
const result = [];
grades.forEach(el => {
const nextMultiple = ((Math.floor(el/5))*5) + 5;
console.log(`${el}의 multiple은 ${nextMultiple}`);
if(el < 38) {
result.push(el)
} else if(Math.abs(nextMultiple - el) < 3) {
result.push(nextMultiple)
} else {
result.push(el)
}
})
return result
}
728x90
'World > Coding Test' 카테고리의 다른 글
| HackerRank_Apple and Orange (0) | 2023.04.12 |
|---|---|
| Leetcode_121. Best Time to Buy and Sell Stock (0) | 2023.04.06 |
| HackerRank_Birthday Cake Candles (0) | 2023.04.05 |
| HackerRank_Staircase (0) | 2023.04.02 |
| HackerRank_Plus Minus (0) | 2023.04.02 |
댓글