https://school.programmers.co.kr/learn/courses/30/lessons/12982
import java.util.Arrays;
class Solution {
public int solution(int[] d, int budget) {
int answer = 0;
Arrays.sort(d); // ์ค๋ฆ์ฐจ์ ์ ๋ ฌ
for(int i = 0; i < d.length; i++){
budget = budget - d[i]; // ์ต๋ํ ๋ง์ ๋ถ์ ๋ฌผํ ๊ตฌ๋งคํ๋๋ก
if(budget >= 0){
answer += 1;
}
else{ // ์์ฐ ๊ธ์ก๋ณด๋ค ํฌ๋ฉด ๋ฉ์ถค
break;
}
}
return answer;
}
}