saketkandoi
KarishmaB What is wrong with below approach?
XX7 -> This way 100 numbers are possible.
X7X -> This way 100 numbers are possible.
7XX -> This way 100 numbers are possible.
Total 300. But there will few same number such as 777 (counted thrice), 77 (counted twice). So we will have to subtract it.
Answer will come 297
There are two different concepts:
How many times is the number 7 written? You will write 7 three times in 777 so it will be counted 3 times. You are not to remove 2 out of it.
How many numbers will have 7 in them? Now 777 is only one such number so you will count it only once.
Since our question asks us to find how many times 7 was written, it was written 100 times in hundreds place, 100 times in tens place and 100 times in units place so total 300 times.