Tap here to switch tabs
Problem
Submissions

Problem: Bold Words in String

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

Statement

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

If two or more bolded substrings overlap or are directly consecutive, they should be merged and enclosed within a single pair of <b> and </b> tags to minimize the total number of tags used.

Return the resulting string after bolding all matching substrings.

Constraints:

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

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

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

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

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Bold Words in String

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

Statement

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

If two or more bolded substrings overlap or are directly consecutive, they should be merged and enclosed within a single pair of <b> and </b> tags to minimize the total number of tags used.

Return the resulting string after bolding all matching substrings.

Constraints:

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

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

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

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