You are viewing a single comment's thread. Return to all comments →
Here is my c++ solution, you also have a vidéo explanation here : https://youtu.be/DFQO52aB-qI
int maximumToys(vector<int> prices, int k) { sort(prices.begin(), prices.end()); int i = 0; while(i < prices.size() && k >= prices[i]){ k -= prices[i]; i++; } return i; }
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 →
Here is my c++ solution, you also have a vidéo explanation here : https://youtu.be/DFQO52aB-qI