Python O(NlogN) time solution. Explained
The idea behind it is simple:\nsort the coins, and every time we take the smallest available (greedy and dp like)\ncur_max tracks the max consecutive we can mak
The idea behind it is simple:\nsort the coins, and every time we take the smallest available (greedy and dp like)\ncur_max tracks the max consecutive we can make.\n* if we have a "1", then we know for sure we can make the next number (so: cur_max +=1) (Actually this case is already covered in the next if condition "coin <= cur_max+1", but I hope by separating this case out there, things are clearer)\n* if we have a coin "k+1" but cur_max is "k", that means we can make any number from 0 to k, so by just adding k to them, we can also make any number from k to k+(k+1). The same applies if we have any coin "j" where j < k. (we can make numbers from 0 to k+j)\n* if we have a coin that\'s bigger than the cur_max+1, we know we cannot make cur_max + 1. As the coins are sorted, we don\'t need to look further.\n\nwe return cur_max + 1 because we don\'t return the max number we can make, but the amount of numbers. From 0 to cur_max, there are exactly (cur_max + 1) numbers.\n\n```\nclass Solution:\n    def getMaximumConsecutive(self, coins: List[int]) -> int:\n        cur_max = 0\n        coins.sort()\n      \n        for coin in coins:\n            if coin == 1:\n                cur_max += 1\n            elif coin <= cur_max+1:\n                cur_max += coin\n            else: #coin > cur_max + 1\n                break\n        \n        return cur_max+1\n```\n\nTime complexity is O(NlogN) because of the sorting\nSpace complexity is O(N) (timsort in python)
['Python']