There are exactly nine 2-digit numbers which have two digits the same: 11, 22, ..., 99.
How many 3-digit numbers have two digits the same?
In general, the first digit can be 1-9, the second digit can be 0-9, and the final digit can be 0-9; so there are 91010 = 900 3-digit numbers in total. Of these it is possible to have none, two, or three digits the same.
Let us consider no digits being the same: the first digit can be 1-9, then second digit can be any one of nine digits and the final digit can be any one of eight. That is, there are 998 = 648 3-digit numbers for which no digits are the same.
Clearly there are nine 3-digit numbers for which all the digits are the same: 111, 222, ..., 999.
Hence there are 900 648 9 = 243 3-digit numbers for which two digits are the same.
How many 4-digit numbers have two digits the same?
Investigate n-digit numbers.