Skip to content

Commit 712c6ce

Browse files
committedAug 25, 2021
2021-08-24
1 parent 0b8b9a0 commit 712c6ce

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed
 
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class Solution(object):
2+
def getMaximumGenerated(self, n):
3+
"""
4+
:type n: int
5+
:rtype: int
6+
"""
7+
nums = [0, 1]
8+
for i in range(2, n + 1):
9+
if i % 2 == 0:
10+
nums.append(nums[i // 2])
11+
else:
12+
nums.append(nums[i // 2] + nums[i // 2 + 1])
13+
# print nums
14+
return max(nums) if n else 0

0 commit comments

Comments
 (0)