Multi-Pattern String Replacement
Given a text string and a set of target words, find and replace all occurrences of those words in the text, treating whitespace as a special character delimiter. The goal is an efficient solution that handles multiple patterns simultaneously — an optimal approach uses a Trie data structure and the Aho-Corasick algorithm for multi-pattern matching.
Asked at:
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
Early July, 2026
Senior
find all occurrences of a set of words (with at least whitespace as special character) in a text and replace them with another string. Trie to use as solution, and Aho-Corasick algo for optimal time complexity
Hello Interview Premium
Your account is free and you can post anonymously if you choose.