Challenge: Generate Binary Numbers From 1 to n Using Queue
Can you generate binary numbers from 1 to any given number "n"?
We'll cover the following
Problem Statement
Implement a function findBin(n)
, which will generate binary numbers from to in the form of a string using a queue. 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.