Annotate substrings in a paragraph with pronunciation XML tags

Asked at HeyGen · Coding Questions · Difficulty: Medium

Given a paragraph `text` and a glossary `glossary` consisting of pairs `(substr, pronunciation)`, return a new string where every occurrence of `substr` found in `text` is wrapped with an XML tag:

Loading the problem…