cswork / libraryOpen practice workspace

Interview questions · Bloomberg

Generate all strings by expanding wildcards

This question evaluates algorithmic string manipulation and combinatorial enumeration skills, focusing on handling wildcard characters and generating all possible binary outcomes from a pattern.

Problem

Given a string s consisting only of characters '0', '1', and '*', replace every '*' with either '0' or '1' and return all possible resulting binary strings.

You may return the results in any order.

Example

Input: "01*"

Output: ["010", "011"]

Input: "1*0*"

Output: ["1000","1001","1100","1101"]

Community answers

Nothing here yet.

Join in on CSWork →