(프로그래머스) 예산

유지원·2022년 4월 4일
0

프로그래머스

목록 보기
18/66

문제 링크

https://programmers.co.kr/learn/courses/30/lessons/12982?language=javascript


Javascript

function solution(d, budget) {
	let answer = 0;
	let money = 0;
	d.sort((a,b) => a-b).forEach(function(val){
		money += val;
		if(money <= budget){
			answer++;
		}
	})
	return answer;
}
profile
👋 https://github.com/ujw0712

0개의 댓글