1646. Get Maximum in Generated Array
Содержание
class Solution:
def getMaximumGenerated(self, n: int) -> int:
if n < 2:
return n
nums = [0] * (n + 1)
nums[1] = 1
for i in range(2, n + 1):
nums[i] = nums[i >> 1] if i % 2 == 0 else nums[i >> 1] + nums[(i >> 1) + 1]
return max(nums)