Challenge: Generate Binary Numbers from 1 to n using a Queue
Can you generate binary numbers from 1 to any given number "n"?
We'll cover the following
Problem Statement
Implement a function find_bin(n)
which will generate binary numbers from till in the form of a string using a queue. The MyQueue
and MyStack
classes are provided in all of these challenges. An illustration is also provided for your understanding.
Input
A positive integer
Output
Returns binary numbers in the form of strings from 1 up to n
Sample Input
n = 3
Sample Output
result = ["1","10","11"]
Level up your interview prep. Join Educative to access 70+ hands-on prep courses.