You are viewing a single comment's thread. Return to all comments →
static int maximumToys(int[] prices, int k) {
int count=0,sum=0; Arrays.sort(prices); for(int i=0;i<prices.length;i++) { if(sum <= k) { sum=sum+prices[i]; count++; } } return count-1; Very simple Java solution
Seems like cookies are disabled on this browser, please enable them to open this website
Mark and Toys
You are viewing a single comment's thread. Return to all comments →
static int maximumToys(int[] prices, int k) {