Description
Submission
class Solution { public: int getMaximumConsecutive(vector<int>& coins) { sort(coins.begin(), coins.end()); int curMax = 0; for(int c: coins) { if(c > curMax + 1) break; curMax += c; } return curMax+1; } }; // for a new coin c: // [0, ..., curMax] X [c, ...+c, curMax+c] // c > curMax + 1