Recently, I was asked to devise a function that would take a single string containing any of 1's, 0's, and ?'s (ex: "10?10?1", "00???11", "????", etc) as an input, and return a list of strings containing all the unique one-zero permutations of the input string.
For an input of "10?1?", the answer would be the list containing "10010", "10110", "10011", and "10111".
I was able to devise a function that did this, but it was brute force in nature and I am interested in a cleaner function that's O(2^n) in complexity. Providing an algorithm and/or implementation would be greatly appreciated, thank you!