Skip to content

Latest commit

 

History

History
19 lines (15 loc) · 446 Bytes

1646.-get-maximum-in-generated-array.md

File metadata and controls

19 lines (15 loc) · 446 Bytes

1646. Get Maximum in Generated Array

class Solution:
    def getMaximumGenerated(self, n: int) -> int:
        
        ##奇偶数,数字大点就会是数学了
        res = [0] *100
        res[0] = 0
        res[1] = 1
        for i in range(2,100):
            if i%2:
                res[i] = res[i//2] + res[i//2 + 1]
            else:
                res[i] = res[i//2]
                
        return max(res[:n+1])