Add Bold Tag in String
Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.
Practice this as a mock interviewFree to start, no account neededProblem
You are given a string s and a list of keywords words. Every character of s that lies inside **any** occurrence of any keyword should be bolded. Occurrences may overlap.
Wrap each maximal run of bolded characters in a single pair of tags <b> and </b>. Two bold stretches that overlap **or touch** (one ends right where the next begins) form one run and get one pair of tags.
Return the resulting string. If nothing is bolded, return s unchanged.
Examples
Constraints
- `1 <= s.length <= 1000`
- `0 <= words.length <= 100`
- `1 <= words[i].length <= 1000`
- `s` and `words[i]` contain only English letters and digits
- All values in `words` are distinct
What the interviewer grades
A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.