You are viewing a single comment's thread. Return to all comments →
c#
public static int maximumToys(List prices, int k)
{ prices.Sort(); int spend = 0; int toys = 0; int i = 0; while (spend < k) { spend += prices[i]; i++; toys++; } toys--; 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 →
c#
public static int maximumToys(List prices, int k)