GREEDY | INTUITION | C++ SOLUTION
Intuition\nWe can have a prefixSum which will indicate sum of all elements from start till current index. If curr_index >= prefixSum + 1, which means it is unat
# Intuition\nWe can have a prefixSum which will indicate sum of all elements from start till current index. If curr_index >= prefixSum + 1, which means it is unattainable.\n\n# Approach\nHave a prefixSum which checks if coins[curr_idx] >= prefixSum + 1.If yes, break the loop and return ans;\n\n# Complexity\n- Time complexity: $$O(nlogn)$$ \n\n- Space complexity: $$O(1)$$ \n\n# Code\n```\nclass Solution {\npublic:\n    int getMaximumConsecutive(vector<int>& coins) {\n        sort(coins.begin(), coins.end());\n        int preSum = 0;\n        \n        for(int coin: coins){\n            if(coin <= preSum + 1){\n                preSum += coin;\n            }\n            else break;\n        }\n\n        return preSum + 1;\n    }\n};\n```
['C++']