topic:
1798. You can construct the maximum number of continuity
Thought:
nums = [1,4,10,3,1]
1 ~ 10 All can be constructed,so11 ~ 20As well。
Traversal nums = [1,1,3,4,10]
, if i<= Earlier+1
$i_0(1) <= 0+1; i_1(1) <= 1+1; i_2(3) <= 2+1; i_3(4) <= 5+1; i_4(10) <= 9+1$
, ExplainiThe previous numbers can be constructed。if i > m + 1
It means that it cannot be constructed。
Code:
1 | class Solution: |
1 | func getMaximumConsecutive(coins []int) int { |