Special Numbers
Medium Accuracy: 26.69% Submissions: 176 Points: 4

A number is a special number if it’s digits only consist 0, 1, 2, 3, 4 or 5. Given a number N and we have to find N-th Special Number. 


Example 1:

Input:
N = 6
Output: 5
Explanation: First 6 numbers are
( 0, 1, 2, 3, 4, 5 )


​Example 2:

Input: 
N = 7
Output: 10
Explanation: First 7 numbers are
( 0, 1, 2, 3, 4, 5, 10 )


Your Task:
You don't need to read input or print anything. Your task is to complete the function getSpecialNumber() which accepts an integer N and return Nth Special Number.


Expected Time Complexity: O(LogN)
Expected Auxiliary Space: O(1)


Constraints:
1 <= N <= 105

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.

Output Window