class Solution:
def maxA(self, n):
"""
:type N: int
:rtype: int
"""
dp = [i for i in range(n+1)]
if n<=6:
return(dp[n])
for i in range(7,n+1):
dp[i] = max(dp[i4]*3,dp[i5]*4)
return(dp[n])
Python, Simple O(n) code (not O(n^2) like most of the posts)

@paulalexis58 said in Python, Simple O(n) code (not O(n^2) like most of the posts):
dp[i] = max(dp[i4]*3,dp[i5]*4)
Can you explain how you come up with this?