Easy · Backtracking

Generate Binary Strings

Given an integer n, return all 2^n strings of length n that use only the characters '0' and '1', in any order.

Examples

Example 1

n = 3

Output: 8 strings

Example 2

n = 2

Output: 4 strings

Rebuild it in the studio

Open every published interview problem, solution, scene, and memory room free, with no account.

More Backtracking problems