class Solution(object):

def countNumbersWithUniqueDigits(self, n):

"""

:type n: int

:rtype: int

"""

def search(used, length):

count = 1

if length == 0:

return count

for i in range(0, 10):

if not used[i]:

used[i] = True

count += search(used, length-1)

used[i] = False

return count

if n > 10:

return self.countNumbersWithUniqueDigits(10)

if n == 0:

return 1

used = [False for i in range(0, 10)]

count = 1 #x = 0

for i in range(1, 10):

used[i] = True

count += search(used, n-1)

used[i] = False

return count