코딩테스트
코딩테스트 연습 > Summer/Winter Coding(~2018) > 예산
안양사람
2020. 7. 16. 23:47
728x90
SMALL
function solution(d, budget) {
d.sort((a, b) => {
return a - b;
});
let ans=0;
for(let i=0;i<d.length;i++){
budget-=d[i];
if(budget>=0){
ans++;
}else{
break;
}
}
return ans;
}
728x90
LIST