924. Generate Binary Strings Without Consecutive 1s
Given an integer n, return all binary strings of length n that do not contain consecutive 1s. Return the result in lexicographically increasing order.
A binary string is a string consisting only of characters '0' and '1'.
Example 1:
Input: n = 3
Output: ["000", "001", "010", "100", "101"]
Explanation: All strings are of length 3 and do not contain consecutive 1s.
Example 2:
Input: n = 2
Output: ["00", "01", "10"]
Now Your Turn!
Pick the correct output for the given inputInput: n = 1
Still unsure what the problem is asking ?
Let’s go through a few more examples, step by step, to make it clearer.
Constraints:
- 1 <= n <= 20