Skip to content

Latest commit

 

History

History
executable file
·
20 lines (11 loc) · 386 Bytes

357.md

File metadata and controls

executable file
·
20 lines (11 loc) · 386 Bytes

357. Count Numbers with Unique Digits

Given an integer n, return the count of all numbers with unique digits, x, where 0 <= x < 10n.

2 => 9 => 100 - 9 3 =>

111,122,133,144,155,166,177,188,199

121

It's a combinations?

Yep, it have a formula to calculate it.

f(k) = 9 * 9 * 8 * ... (9 - k + 2)

for the fixed position. And for each k, we need to sum 1...k.

Celever solution!