O(n) solution in Python


  • 0
    N
    class Solution(object):
        def integerBreak(self, n):
    
            if n==2:
                return(1)
            
            if n==3:
                return(2)
            
            if n==4:
                return(4)
            
            if n>=5:
                result=max(3*self.integerBreak(n-3),3*(n-3))
                return(result)
    

Log in to reply
 

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