Challenge: Generate Binary Numbers from 1 to n using Queue

Can you generate binary numbers from 1 to any given number 'n'? Let's find out.

Problem Statement

Implement a function string* findBin(int n) which will generate binary numbers from 11 to nn stored in an array of type string by making use of a queue.

Input

A positive integer nn.

Output

An array of type string (result) containing binary numbers from 1 up to n.

Sample Input

n = 3

Sample Output

result = {"1","10","11"}

An illustration is also provided for your understanding.

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.