Python max o(n^2)

  • 0
    class Solution(object):
        def integerBreak(self, n):
            :type n: int
            :rtype: int
            res = [0, 1] + [0] * (n - 1)
            for i in range(2, n+1):
                res[i] = max([max(j*(i-j), res[j]*res[i-j], res[j]*(i-j), res[i-j]*j) for j in range(1, i/2+1)])
            return res[n]

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.