Geeksforgeeks

Error

×

Leaderboard

Showing:

Handle | Score |
---|---|

@Ibrahim Nash | 6420 |

@blackshadows | 6376 |

@mb1973 | 5594 |

@Quandray | 5231 |

@akhayrutdinov | 5111 |

@saiujwal13083 | 4510 |

@sanjay05 | 3762 |

@kirtidee18 | 3673 |

@marius_valentin_dragoi | 3522 |

@sushant_a | 3459 |

@verma_ji | 3412 |

Complete Leaderboard | |

Handle | Score |

@codersgroup18 | 783 |

@Manikanta punnam | 605 |

@sriramgoparaju99 | 590 |

@rdakka | 538 |

@praveenbgp6 | 529 |

@prankursharma31 | 518 |

@yashkaril4 | 517 |

@purohitmn02 | 467 |

@sonamnigam1999 | 443 |

@sonamkumari63928 | 441 |

@shubhamstudent5 | 433 |

Complete Leaderboard |

Given a string containing of ‘**0**’, ‘**1**’ and ‘**?**’ - a wildcard character, generate all distinct **binary strings** that can be formed by replacing each wildcard character by either ‘**0**’ or ‘**1**’.

**Example 1:**

**Input: **1??0?101
**Output: **10000101 10001101 10100101 10101101
11000101 11001101 11100101 11101101
**Explanation:
**There will be 8 such possible strings that
can be formed, they are 10000101, 10001101,
10100101, 10101101, 11000101, 11001101,
11100101 and 11101101.

**Example 2:**

Input:10?Output:100 101Explanation:There are 2 such possible strings and they are 100 and 101.

**Your Task:**

You don't need to read or print anything. Your task is to complete the function **generate_binary_string() **which takes the given string as input parameter and returns a vector of strings containing all the possible strings that can be formed.

**Expected Time complexity: **O(2^{n})

**Expected Space complexity: **O(n*2^{n})

**Constraints:**

1 ≤ length of string ≤ 30

**Note:** Number of '**?**' in any string does not exceed 15.

Login to report an issue on this page.

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes
Generate binary string

...