Code RoomMask banned word
MediumPrep Room Coding #578

Mask banned word

CodingAlgorithms & data structuresEntry–Mid~15 min

A moderation filter masks a banned word. Given a message and a non-empty banned word, replace every occurrence of the banned word with asterisks of the same length. Matching is case-sensitive; scan left to right, and after masking an occurrence continue scanning right after it (matches never overlap). For example, censoring 'magic' in 'say the magic word, magic!' gives 'say the ***** word, *****!'.

Implement
censor(message: str, banned: str) → str
Examples
in["say the magic word, magic!","magic"]out"say the ***** word, *****!"
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

0:00 of about 15 min
InputExpectedGot
["say the magic word, magic!","magic"]"say the ***** word, *****!"not run yetsample