C++ | O(nlogn)  + O(n)
Intuition\nFirst sort the elements. Why ??\nFor e.g. coins = [1,1,1,4]. Here the numbers less than 4 can only be generated by elements in the coins array with v
# Intuition\nFirst sort the elements. Why ??\nFor e.g. coins = [1,1,1,4]. Here the numbers less than 4 can only be generated by elements in the coins array with value less than 4. There to generate the numbers starting from 1 to ... we need coins to be sorted order.\n\nExplanation for: \n    if(x <= rv+1)rv += x;\n    else return rv+1;\n\nIf on reaching a number x in the sorted coins array, we still not have x-1, then we cannot generate x-1 because the smallest number that can be generated using x, is x. \n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Code\n```\nclass Solution {\npublic:\n    int getMaximumConsecutive(vector<int>& coins) {\n        \n        sort(coins.begin(), coins.end());\n        \n        int rv = 0;\n        for(int x: coins){\n            if(x <= rv+1)rv += x;\n            else return rv+1;\n        }\n        return rv+1;\n    }\n};\n```
['C++']