Python easy solution beats 90%


  • 0
    class Solution(object):
        def check(self, n):
            t = n
            while n:
                r = n%10
                if r ==0 or t%r != 0:
                    return False
                n = n/10
            return True
        
        def selfDividingNumbers(self, left, right):
            """
            :type left: int
            :type right: int
            :rtype: List[int]
            """    
            res = []
            for num in range(left,right+1):
                if self.check(num):
                    res.append(num)
            return res
    
    

Log in to reply
 

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