Let N be the number of 4 digit numbers formed with atmost two distinct digits.Then the last digit of N is My answer of total ways is $2^4\dfrac{9\times10}{2}=720$ but $0$ should not be in the first place, number of their ways is $9\times2^3=72$. Required answer is $720-72=648$. But in some books answer is given $576$. Which is correct tell me.
 A: You have counted $1111$ several times, once for each 'other digit'
A: Let $N$ be the number of 4 digit numbers that have at most 2 different digits occurring in them. 
There are $9$ numbers that have at most (so exactly $1$) digit(s).
To get two digits exactly, we have two cases: we have a $0$ which does not occur in first place so $9$ other digits could be picked, and after that we can make $1 \times 2^3 - 1 = 7$ many numbers of $4$ digits using both digits (the -1 is to exclude the case of all digits equal). So with $0$ we have $9 \times 7 = 63$ options.
With two digits, both not $0$, we have $\binom{9}{2} = \frac{9 \times 8}{2} = 36$ choices of digits, and we have $2^4 -2 = 14$ (now excluding 2 constant sequences of digits) options after that. So $14 \times 36 = 504$ options with tow non-zero digits.
In total I get $504 + 63 + 9 = 576$ options. So "some books" agree with me.
Your solution overcounts the constant sequences, essentially.
You enumerate 1111 among the options when you picked digits 0,1 and 1,2 and 1,9 etc. 
