Simple Python


  • 0
    class Solution(object):
        def selfDividingNumbers(self, left, right):
            """
            :type left: int
            :type right: int
            :rtype: List[int]
            """
            r = []
            for i in range(left, right + 1):
                if self.check(i):
                    r.append(i)
            return r
        
        def check(self, num):
            digit = list(str(num))
            if '0' in digit:
                return False
            for i in digit:
                if num % int(i) != 0:
                    return False
            return True

Log in to reply
 

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