Skip to content

Practice Generate Binary Strings Without Adjacent Zeros

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#3211
LeetCode Problem

Generate Binary Strings Without Adjacent Zeros

Problem Statement

You are given a positive integer n. A binary string x is valid if all substrings of x of length 2 contain at least one "1". Return all valid strings with length n, in any order.

Source: Generate Binary Strings Without Adjacent Zeros on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
n = 3
Output
["010","011","101","110","111"]

# Example 2

Input
n = 1
Output
["0","1"]

Constraints

1 <= n <= 18

Related LeetCode Problems

Practice more problems similar to Generate Binary Strings Without Adjacent Zeros.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.