math problem, python AC 39ms


  • 0
    V
    class Solution(object):
        def integerBreak(self, n):
            """
            :type n: int
            :rtype: int
            """
            if n <= 3:
                return n-1
            
            mod = n%3
            res = n//3
            
            if mod == 1:
                res -= 1
                return (3**res)*2*2
            
            if mod == 0:
                return 3**res
            
            return (3**res)*2
    

Log in to reply
 

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