You are viewing a single comment's thread. Return to all comments →
Hey guys...try this!
int maximumToys(vector <int> prices, int k) { sort(prices.begin(),prices.end()) ; int count = 0 ; for(int i = 0 ; i < prices.size() ; i++) { if(prices[i] <= k) { k -= prices[i] ; count++ ; } } return count ; }
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 →
Hey guys...try this!