Easy to understand C++ solution, beats 96% in time and 79% in space.
\nPlease upvote if u find this useful <3\n\n# Intuition\n- If we can make first x values and we have a value y, we can make all the values that <= x+y and >=y\n
![image.png](https://assets.leetcode.com/users/images/c9c9c886-21a0-4681-8f98-5ec4767cf832_1718514185.398779.png)\n**Please upvote if u find this useful <3**\n\n# Intuition\n- If we can make first x values and we have a value y, we can make all the values that <= x+y and >=y\n- => X would start at 0 and if x <=coins[i], x would be x+coins[i]\n\n# Complexity\n- Time complexity:\n**O(n*log2(n))**\n\n- Space complexity:\n**O(1)**\n\n# Code\n```\nclass Solution {\npublic:\n    int getMaximumConsecutive(vector<int>& coins) {\n        sort(coins.begin(),coins.end());\n        int n=coins.size(),consecutive=1;\n        for(int i=0;i<n;i++){\n            if (coins[i]<=consecutive){\n                consecutive+=coins[i];\n            } \n        }\n        return consecutive;\n    }\n};\n```
['C++']