o(nlog(n)) | cpp | easy to solve
class Solution {\npublic:\n    int getMaximumConsecutive(vector& coins) {\n      \n       sort(coins.begin(),coins.end());\n        long long i,j,k=0,l,m;\n    
class Solution {\npublic:\n    int getMaximumConsecutive(vector<int>& coins) {\n      \n       sort(coins.begin(),coins.end());\n        long long i,j,k=0,l,m;\n        i=j=0;\n        while(j<coins.size())\n        {\n            if(k>=coins[j])\n            {\n                k+=coins[j];\n                j++;\n            }\n            else if(k+1==coins[j])\n            {\n                k+=coins[j];\n                j++;\n                \n            }\n            else\n                return k+1;\n        }\n        return k+1;\n        \n    }\n};
[]