Short C++, O(NLogN) Time and O(1) Space
\tclass Solution {\n\tpublic:\n    int getMaximumConsecutive(vector& coins) {\n        int n=coins.size();\n        sort(coins.begin(),coins.end());\n        in
\tclass Solution {\n\tpublic:\n    int getMaximumConsecutive(vector<int>& coins) {\n        int n=coins.size();\n        sort(coins.begin(),coins.end());\n        int ans=1;\n        for(int i=0;i<n;i++){\n            if(coins[i]<=ans) ans+=coins[i];\n        }\n        return ans;\n    }\n\t};
['C', 'C++']