Created
August 13, 2021 10:11
-
-
Save lllilllilllilili/6e297241dc6efeea8f88491b52e35439 to your computer and use it in GitHub Desktop.
프로그래머스_실패율
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function solution(N, stages) { | |
var answer = []; | |
var arr =[] | |
var total = stages.length; | |
for(let i=1; i<=N; i++){ | |
let count = stages.filter(element => i===element).length; | |
arr.push({number : i, failRate : (count/total)*100}); | |
total-=count; | |
} | |
arr.sort((a,b)=>{ | |
if(a.failRate!=b.failRate) | |
return b.failRate-a.failRate | |
else{ | |
return a.number-b.number | |
} | |
}) | |
console.log(arr) | |
return arr.map(element=>element.number); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment