Challenge 1: 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

The input is a positive integer nn.

Output

The output is 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 80+ hands-on prep courses.