Code Room
CodingMediumcod-g1385
Subject StringsLevel Entry–Mid~15 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

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.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.