Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solution(d, budget) {
- const list = d.sort((a,b) => a-b);
- let b = budget;
- let count = 0;
- for (let i = 0; i < d.length; i++) {
- if (b - list[i] >= 0) {
- b -= list[i];
- count++;
- } else
- return count;
- }
- return count;
- }
Add Comment
Please, Sign In to add comment