Python greedy with sorting with explanation (330 and 2952 variant)
Intuition\n Describe your first thoughts on how to solve this problem. \n1. Initialize res = 1 since we count from 0;\n2. Sort coins;\n3. For each coin in coins
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n1. Initialize res = 1 since we count from 0;\n2. Sort coins;\n3. For each coin in coins:\n  - if coin > res, then the consecutive values cannot expand to the right;\n  - if coin == res, then the consecutive values can be just perfectly expanded, res = coin + res;\n  - if coin < res, then the consecutive values can be expanded, but not as "efficient" as above, res = coin + res.\n# Approach\n<!-- Describe your approach to solving the problem. -->\nGreedy with sorting.\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nO(n * log(n))\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nO(n) due to sorting in Python\n# Code\n```\nclass Solution:\n    def getMaximumConsecutive(self, coins: List[int]) -> int:\n        res = 1\n        coins.sort()\n        for coin in coins:\n            if coin > res:\n                break\n            else:\n                res += coin\n        \n        return res\n```
['Python3']