문제 🔽
https://school.programmers.co.kr/learn/courses/30/lessons/150370
다른사람 풀이 🔽
function solution(d, budget) {
return d.sort((a, b) => a - b).reduce((count, price) => {
return count + ((budget -= price) >= 0);
}, 0);
}
내풀이🔽
1. 성공 ⭕
function solution(d, budget) {
let answer = 0;
d.sort((a,b)=>a-b)
for(let money of d){
if(budget>=money){
budget-=money;
++answer;
}else{
break;
}
}
return answer
}
느낀점🔽
생략