Nth Natural Number

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

Example 1:

Input:
N = 8
Output:
8
Explanation:
After removing natural numbers which contains
digit 9, first 8 numbers are 1,2,3,4,5,6,7,8
and 8th number is 8.
i am getting correct output but its vey time taking taking algo and showing tle , how can i optimise my code in o(log n)https://ide.codingblocks.com/s/413506

hello @poojadas408

since 9 is not allowed in this problem base 10 (decimal system) is now reduce to base 9.

so for this problem u simply have to convert N (given in base 10 ) to base 9.

Input: 10000021409 Its Correct output is: 27726721438 And Your Code’s output is: 1956917662

Input: 10000021409 Its Correct output is: 27726721438 And Your Code’s output i https://ide.codingblocks.com/s/413506s: 1956917662 i am failing this test case by theis algo which you mentioned check it once

image
make all variable long long

thank you so much…

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.