Generate All Binary Strings
You are asked to create a recursive function to generate all the binary strings of length n.
Binary strings are sequences of 1's and 0's. For example, for n=3, the binary strings are 000, 001, 010, 011, 100, 101, 110, 111.
The input of the program is a single integer n that represents the length of the binary strings.
The output of the program should be all the binary strings of length n each on a new line in no particular order.
Input | Output |
|---|---|
2 | 00 |
Constraints
Time limit: 2 seconds
Memory limit: 512 MB
Output limit: 1 MB