Python 2 lines


  • 0
    class Solution(object):
        def countNumbersWithUniqueDigits(self, n):
           l=[1,9,9,8,7,6,5,4,3,2,1]
           return reduce(lambda x,y:x+y,[reduce(lambda x,y:x*y,l[:i+1]) for i in range(n+1)])
    

Log in to reply
 

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