Python solution


  • 0
    H
    class Solution(object):
        def countNumbersWithUniqueDigits(self, n):
            """
            :type n: int
            :rtype: int
            """
            ans=1
            for i in xrange(1,n+1):
                term=9
                for i in xrange(1,i):
                    term*=10-i
                ans+=term
            return ans

Log in to reply
 

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