首页 > 其他分享 >【LeetCode】1798. 你能构造出连续值的最大数目

【LeetCode】1798. 你能构造出连续值的最大数目

时间:2023-02-04 16:14:16浏览次数:45  
标签:1798 int coins 构造 数目 LeetCode

  • 思路很巧妙
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;
    }
};

标签:1798,int,coins,构造,数目,LeetCode
From: https://www.cnblogs.com/zjacky/p/17091734.html

相关文章