dp bottom up solution


  • 0
    M
        def integerBreak(self, n):
            r = [0] * (n+1)
            r[1] = 1
            for i in xrange(2, n+1):
                for j in xrange(1, i):
                    r[i] = max(r[i], (i-j)*r[j], (i-j) * j)
            return r[n]
    

Log in to reply
 

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