[Python] Permutation rule + Find the numbers without repeted digits
\n\nclass Solution:\n    def numDupDigitsAtMostN(self, n: int) -> int:\n        \n        nums = [int(i) for i in str(n+1)] # digits in n+1\n        d = len(num
\n```\nclass Solution:\n    def numDupDigitsAtMostN(self, n: int) -> int:\n        \n        nums = [int(i) for i in str(n+1)] # digits in n+1\n        d = len(nums) # number of digits in n+1\n        res = 0 # number of no duplicates\n        \n        # count no duplicates for numbers with <d digits\n        for i in range(1,d):\n            res += 9 * math.perm(9,i-1)\n        \n\t\t# count no duplicates for numbers with d digits and smaller than n\n        for i, x in enumerate(nums):\n            if i == 0:\n                digit_range = range(1,x) # first digit can not be 0\n            else:\n                digit_range = range(x)\n                \n            for y in digit_range:\n                if y not in nums[:i]:\n                    res += math.perm(9-i,d-1-i)\n            if x in nums[:i]: break\n                \n        return n - res\n```\n        \n\t\t
['Combinatorics', 'Python']