Python code


  • 0
    T
    class Solution(object):
        def selfDividingNumbers(self, left, right):
            numbers = list(range(left, right+1))
            result = []
            for i in range(len(numbers)):
                buff = []
                for j in range(len(str(numbers[i]))):
                    number = str(numbers[i])[j]
                    if not int(number) == 0:
                        buff.append(numbers[i] % int(number) == 0)
                    if int(number) == 0:
                        buff.append(False)
                if all(buff):
                    result.append(numbers[i])
            return result
    

Log in to reply
 

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