# Leetcode 357 - Count nums with unqiue digits

`Note:`

`DP`

- Made a mistake trying to use pure math. But it does involve some maths.
`dp[i]`

means the`number of n-digit nums with unique digits`

.`dp[i]`

are nums that has`one more digit`

than`dp[i-1]`

.- We cannot use those
`0 - 9`

that have been used before. How many left for us? - For
`2-digit`

, it’s`9 * 9`

(The first 9 is 0-9, then we can use 0 on the last digit, still 9 numbers) - For
`3-digit`

, it’s`9 * 9 * 8`

. - Based on permutation rules,
`dp[i] = dp[i-1] * (11 - i)`

. - Add
`dp[0]`

till`dp[n]`

`Question:`

Given an integer `n`

, return the count of all numbers with unique digits, x, where `0 <= x < 10^n`

.

`Example:`

1 | Input: n = 2 |

`Code:`

`DP`

1 | /** |

`DFS`

1 | if (n === 0) return 1; |