FastPrepDetect Blocked Chat Phrases
Problems/Detect Blocked Chat Phrases

Detect Blocked Chat Phrases

WhatNot logoWhatNot● MediumNEW GRADFULLTIMEPHONE SCREENONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported as the second part of a chat safety question, once in a new grad onsite at Whatnot and twice in phone screens for experienced hires. The first part, flagging messages that contain blocked single words, is its own problem here. In this part each blocked entry has several words, and a message only counts as unsafe when the whole phrase shows up with its words side by side.

The reports disagree on punctuation: two of them strip it, and one keeps it as part of a word. Here, we keep the word rule of the first part. A word is a run of English letters, case does not matter, and any other character splits words. The answer has one flag per message.

Our version is about 85% the same as the reported question.

You are given an array of chat messages and a list of blockedPhrases. In message order, return true for each message that contains a blocked phrase and false for each that does not.

  • A word is a complete group of consecutive English letters A-Z or a-z. Every other character separates words.
  • Each blocked phrase is one or more lowercase words separated by single spaces.
  • A message contains a phrase when the phrase's words appear in the message one right after another, in the same order. Ignore uppercase and lowercase differences when comparing words.
  • Whole words must match. A phrase word inside a longer word does not count.
  • Messages are independent, and a phrase cannot span two messages.
  • An empty message or an empty phrase list never produces a match. Repeated phrases have no extra effect.

Function

detectBlockedPhrases(messages: String[], blockedPhrases: String[]) → boolean[]

Examples

Example 1

messages = ["Free money here","money free","get FREE   money!"]blockedPhrases = ["free money"]return = [true,false,true]

Case is ignored, and the extra spaces and the "!" only separate words, so the first and third messages contain free money. The second message has both words in the wrong order.

Example 2

messages = ["freemoney now","free moneys","free-money"]blockedPhrases = ["free money"]return = [false,false,true]

"freemoney" and "moneys" are single words that do not equal the phrase words. In "free-money", the dash separates two words, so the phrase is there.

Example 3

messages = ["go go live now","go live"]blockedPhrases = ["go live now","spam"]return = [true,false]

The first message has the words go, go, live, now. The last three of them are the phrase go live now. The second message stops before now, so it only has part of the phrase.

Example 4

messages = ["","spam"]blockedPhrases = []return = [false,false]

With no blocked phrases, no message is flagged. An empty message has no words.

Constraints

  • 0 <= messages.length, blockedPhrases.length <= 100
  • Each message has at most 1000 printable ASCII characters.
  • Each blocked phrase has 1 to 10 words separated by single spaces, with no leading or trailing space.
  • Each word of a blocked phrase has 1 to 20 lowercase English letters.

More WhatNot Onsite Interview questions

  • User Journey PathsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Search a 2D MatrixPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Minimum Remove to Make Valid ParenthesesONSITE INTERVIEW · Seen Dec 2024
  • Number of IslandsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2024
  • Merge Two Sorted ListsONSITE INTERVIEW · Seen Jul 2024
  • Number of Submatrices That Sum to TargetONSITE INTERVIEW · Seen Jul 2024
  • Parse and Store Log RecordsONSITE INTERVIEW · Seen Oct 2023
  • Room Occupancy at Query TimesONSITE INTERVIEW · Seen Oct 2023
  • K Smallest Values in a StreamPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2022
  • Average Purchase PriceONSITE INTERVIEW · Seen Sep 2022

Similar questions at other companies

  • Transform Dotted Keys into a Nested MapProofpoint · ONSITE INTERVIEW
  • Longest-Match Tokenizer with Unknown SymbolsAnthropic · ONSITE INTERVIEWAnthropic interview questions
  • Dynamic Prefix Query CountsGoogle · ONSITE INTERVIEWGoogle interview questions
  • Maximum Move ScoreAmazon · PHONE SCREEN
  • Phrase Covering the Most WordsZip · PHONE SCREENZip interview questions
  • In-Memory Directory and File OperationsSquarepoint Capital · ONSITE INTERVIEWSquarepoint Capital interview questions
  • Indexed API Field Pattern QueriesStripe · PHONE SCREENStripe interview questions
  • Find Repeated Substrings Ignoring CaseDatadog · PHONE SCREENDatadog interview questions
  • File System PathsCapital One · ONSITE INTERVIEWCapital One interview questions
  • Common Words from Two ReadersAkuna Capital · PHONE SCREENAkuna Capital interview questions

Interview reports that mention this question

  • Whatnot SWE New Grad Second Technical Interview: 8 Experiences

WhatNot interview experiences

  • Whatnot interviews · October 2026
  • Whatnot Experienced SWE Phone Screen Questions: 2 Experiences
  • Whatnot SWE Interview Questions: 6 Experiences
All WhatNot interview questionsSee WhatNot hiring insights
Saved
class Solution {
    public boolean[] detectBlockedPhrases(String[] messages, String[] blockedPhrases) {
        // write your code here
    }
}
Checking account…