Nth natural number after removing digit = d;

//Given a positive integer N. You have to find Nth natural number after removing all the numbers containing digit D.

Example 1:

Input:
N = 8
D = 9
Output:
8
Explanation:
After removing natural numbers which contains
digit D = 9, first 8 numbers are 1,2,3,4,5,6,7,8
and 8th number is 8.
Example 2:

Input:
N = 8
D = 9

Output:10

Explanation:
After removing natural numbers which contains
digit 9, first 9 numbers are 1,2,3,4,5,6,7,8,10
and 9th number is 10.

hello @manish99

if d is 9 then its easy otherwise it is going to be tough.
we may try digit dp + binary search but that will not be much effcient.
check this for d=9 -> LINK

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.