Guest User

Untitled

a guest
Jan 22nd, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.29 KB | None | 0 0
  1. function solution(d, budget) {
  2. const list = d.sort((a,b) => a-b);
  3. let b = budget;
  4. let count = 0;
  5. for (let i = 0; i < d.length; i++) {
  6. if (b - list[i] >= 0) {
  7. b -= list[i];
  8. count++;
  9. } else
  10. return count;
  11. }
  12. return count;
  13. }
Add Comment
Please, Sign In to add comment