Tap here to switch tabs
Problem
Submissions

Problem: Add Bold Tag in String

med
30 min
Try to solve the Add Bold Tag in String problem.

Statement

Given a string s and an array of strings words, wrap all occurrences of any substring in s that appears in words with the bold tags <b> and </b>.

If two substrings overlap or are directly consecutive, they should be merged and enclosed within a single pair of bold tags.

Return the modified string after adding the bold tags.

Note: This question is the same as 758758: Bold Words in String.

Constraints:

  • 1≤1 \leq s.length ≤1000\leq 1000

  • 0≤0 \leq words.length ≤100\leq 100

  • 1≤1 \leq words[i].length ≤1000\leq 1000

  • s and words[i] consist of English letters and digits.

  • All the values of words are unique.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Add Bold Tag in String

med
30 min
Try to solve the Add Bold Tag in String problem.

Statement

Given a string s and an array of strings words, wrap all occurrences of any substring in s that appears in words with the bold tags <b> and </b>.

If two substrings overlap or are directly consecutive, they should be merged and enclosed within a single pair of bold tags.

Return the modified string after adding the bold tags.

Note: This question is the same as 758758: Bold Words in String.

Constraints:

  • 1≤1 \leq s.length ≤1000\leq 1000

  • 0≤0 \leq words.length ≤100\leq 100

  • 1≤1 \leq words[i].length ≤1000\leq 1000

  • s and words[i] consist of English letters and digits.

  • All the values of words are unique.