![]() |
VOOZH | about |
Given two positive integer numbers L and R. The task is to convert all the numbers from L to R to binary number.
Examples:
Input: L = 1, R = 4
Output:
1
10
11
100
Explanation: The binary representation of the numbers 1, 2, 3 and 4 are:
1 = (1)2
2 = (10)2
3 = (11)2
4 = (100)2Input: L = 2, R = 8
Output:
10
11
100
101
110
111
1000
Approach: The problem can be solved using following approach.
Below is the implementation of the above approach.
10 11 100 101 110 111 1000
Time Complexity: O(N * LogR) Where N is the count of numbers in range [L, R]
Auxiliary Space: O(N * logR)