题目:原题链接(中等)
标签:排序、贪心算法
解法 | 时间复杂度 | 空间复杂度 | 执行用时 |
Ans 1 (Python) | 152ms (55.26%) | ||
Ans 2 (Python) | |||
Ans 3 (Python) |
解法一:
class Solution:
def getMaximumConsecutive(self, coins: List[int]) -> int:
coins.sort()
now = 0
for coin in coins:
if coin > now + 1:
return now + 1
else:
now += coin
return now + 1