데일리 루틴
52번 - 콜라 문제
https://school.programmers.co.kr/learn/courses/30/lessons/132267
function solution(a, b, n) {
var answer = 0;
let coke = n;
let rest = 0;
while(coke >= a){
rest = coke % a;
coke = parseInt(coke / a) * b;
answer += coke;
coke += rest;
rest = 0;
}
return answer;
}
53번 - 명예의 전당 (1)
https://school.programmers.co.kr/learn/courses/30/lessons/138477
function solution(k, score) {
var answer = [];
var rank = [];
for(let i = 0; i<score.length; i++){
rank.push(score[i]);
rank.sort((a,b) => b - a);
if(i < k - 1){
answer.push(rank[i]);
continue;
}
answer.push(rank[k-1]);
}
return answer;
}