Trains the technique from
LeetCode 3295Report Spam MessageThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A support ticket reaches the desk as a list of lowercase words, words, and the desk keeps a list of barred terms, barred.
The desk holds the ticket back once two of its words match a barred term exactly. Those two can be the same term matched twice, since they are still two words of the ticket.
Return true when the ticket is held back and false when it goes through.
Example 1
Two of the three words of the ticket are barred terms, so the desk holds it.
Example 2
One barred term, but the ticket carries it twice, and two words of the ticket are what the desk counts.
Example 3
Only the second word matches a barred term. The first merely contains one, which is not a match, so one word is all the desk has.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def report_spam(words: list[str], barred: list[str]) -> bool:public boolean reportSpam(String[] words, String[] barred)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.