Description
Solutions
Count Fancy Numbers
šŸ¤˜ INTERN

For the original problem description, pls checkout the image source at the very bottom of this web page šŸ¾šŸ¾

Imagine youā€™re in a magical world where certain numbers are considered "fancy." A number is fancy if, when written in base-4, it only contains the digits 0 and 1ā€”like secret codes known only to wizards. For example, 17 is fancy because its base-4 form, 101, uses only 0s and 1s, while 18 is not, as its base-4 form, 102, contains a forbidden 2. Now, your task is to discover how many of these special, fancy numbers exist below a given number, n. But beware! n can be as big as a billion, so you need a clever methodā€”something faster than just checking every number individually.

Example 1:

Input:  n = 1
Output: 0
Explanation:

There are no positive integers less than 1.

Example 2:

Input:  n = 10
Output: 3
Explanation:

The fancy numbers less than 10 are {1, 4, 5}.

Constraints:
    TO-DO
Thumbnail 0
Thumbnail 1
Testcase

Result
Case 1

input:

output: