Maximum Number of Consecutive Values You Can Make LeetCode solution in Python

1
class Solution:
2
def getMaximumConsecutive(self, coins: List[int]) -> int:
3
cur_max = 0
4
coins.sort()
5

6
for coin in coins:
7
if coin == 1:
8
cur_max += 1
9
elif coin <= cur_max + 1:
10
cur_max += coin
11
else: # coin > cur_max + 1
12
break
13

14
return cur_max + 1

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0