leetcodeSolution to some Leetcode problems written in C++ |
git clone git://git.dimitrijedobrota.com/leetcode.git |
Log | Files | Refs | README | LICENSE |
1798.cpp (275B)
0 class Solution { 1 public: 2 int getMaximumConsecutive(vector<int> &coins) const { 3 sort(begin(coins), end(coins)); 4 int res = 1; 5 for (const int c : coins) { 6 if (c > res) break; 7 res += c; 8 } 9 return res; 10 } 11 };