【LeetCode】1798. 你能构造出连续值的最大数目
- 思路很巧妙
class Solution {
public:
int getMaximumConsecutive(vector<int>& coins) {
sort(coins.begin(),coins.end());
int x = 0;
for(int y:coins)
{
if(y > x + 1) break;
x = x + y;
}
return x + 1;
}
};