Problem 344: (2004 AIME II, 4)
How many positive integers less than 10,000 have at most two different digits?
- One distinct digit: $9$ numbers of each length $1$–$4$, giving $36$.
- Two nonzero digits: $\binom92$ pairs, and $2^k-2$ strings of length $k$ using both: $36\cdot(2+6+14)=792$. Digits $0$ and $a\ne0$: the first digit is $a$ and the rest are not all $a$, giving $9\cdot(1+3+7)=99$.
- Total $36+792+99=927$. The answer is $\boxed{927}$.
How many positive integers less than 1,000 have exactly two different digits?