LC: Add Bold Tag in String - spiralgo/algorithms GitHub Wiki
The Essence:
All characters that will be tagged as bold can be represented using a boolean array. This requires finding all the instances of the words in the dictionary.
After the boolean tags are set, the new string can simply be created by appending the tags when a subarray of true values starts and ends.
Details:
For matching the multiple strings from the dictionary, there are many possible approaches. These including simply utilizing matching each word with KMP or built-in methods, character tries and more complex algorithms such as Aho-Corasick Algorithm.
Further explanation and implementation with built-in string matching can be found here: https://github.com/spiralgo/algorithms/pull/125