SHARE
TWEET

Untitled

a guest Jan 22nd, 2019 79 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top