Back to course home
0% completed
Vote For New Content
Solution: Generate Binary Numbers from 1 to N
Problem Statement
Given an integer N
, generate all binary numbers from 1 to N and return them as a list of strings.
Examples
Example 1
- Input: N = 2
- Output: ["1", "10"]
- Explanation: The binary representation of 1 is "1", and the binary representation of 2 is "10".
Example 2
- Input: N = 3
- Output: ["1", "10", "11"]
- Explanation: The binary representation of 1 is "1", the binary representation of 2 is "10", and the binary representation of 3 is "11".
Example 3
- Input: N = 5
.....
.....
.....
Like the course? Get enrolled and start learning!
On this page