Generate binary string
Submissions: 4590   Accuracy:

22.98%

  Difficulty: Easy   Marks: 2

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

Input:
The first line of input contains a single integer T, denoting the number of test cases. Then T test cases follow. Each test case consist of one line. The first line of each test case consists of a string S.

Output:
Print all binary string that can be formed by replacing each wildcard character.

Constraints:
1 ≤ T ≤ 60
1 ≤ |S| ≤ 30

Example:
Input
1
1??0?101

Output
10000101 10001101 10100101 10101101 11000101 11001101 11100101 11101101

Explanation:
Testcase 1:
There will be 8 such possible strings can be formed, they are 10000101 10001101 10100101 10101101 11000101 11001101 11100101 11101101.

 

** For More Input/Output Examples Use 'Expected Output' option **

Author: rajatjha


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.


to report an issue on this page.