You are viewing a single comment's thread. Return to all comments →
Java Solution
public static int maximumToys(List prices, int k) { // Write your code here Collections.sort(prices); int toys=0; /for(int i=0;i/
int i=0; while(prices.get(i)<k && i<prices.size()){ k=k-prices.get(i); toys=toys+1; i++; } return toys; }
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 →
Java Solution
public static int maximumToys(List prices, int k) { // Write your code here Collections.sort(prices); int toys=0; /for(int i=0;i/