Skip to content

Instantly share code, notes, and snippets.

@lllilllilllilili
Created August 13, 2021 10:11
Show Gist options
  • Save lllilllilllilili/6e297241dc6efeea8f88491b52e35439 to your computer and use it in GitHub Desktop.
Save lllilllilllilili/6e297241dc6efeea8f88491b52e35439 to your computer and use it in GitHub Desktop.
프로그래머스_실패율
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