Detect Blocked Chat Messages
Updated
Problem statement
You are given an array of chat messages and a list of blockedWords. In message order, return true for each message that contains a blocked word and false for each that does not.
For this exercise:
- A word is a complete group of consecutive English letters
A-Zora-z. Every other character separates words. - Ignore uppercase and lowercase differences when comparing words. Blocked words are supplied in lowercase.
- A complete word must match; a blocked word inside a longer word does not count.
- Messages are independent, and a word cannot span messages.
- An empty message or an empty blocked-word list never produces a match. Repeated blocked words have no additional effect.
Function
detectBlockedMessages(messages: String[], blockedWords: String[]) → boolean[]Examples
Example 1
messages = ["A SPOILER!","spoilers ahead","normal chat"]blockedWords = ["spoiler"]return = [true,false,false]Matching ignores English letter case and requires the entire token: spoilers does not equal spoiler.
Example 2
messages = ["spam2offer","offer_spam",""]blockedWords = ["spam"]return = [true,true,false]Digits and underscores separate tokens. An empty message contains no token.
Example 3
messages = ["hello","HELLO"]blockedWords = []return = [false,false]An empty blocked-word list flags nothing.
Constraints
- For this exercise, assume
0 <= messages.length, blockedWords.length <= 100. - Each message has at most
1000printable ASCII characters. - Each blocked word has
1to20lowercase English letters.
More WhatNot Phone Screen questions
- Merge Sorted Squares of Two ArraysPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Adjacent Pair and Run RemovalPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- User Journey PathsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- User Journey Paths from a Log StreamPHONE SCREEN · Seen Nov 2026
- Reachable Exits in an Obstacle GridPHONE SCREEN · Seen Oct 2026
- Palindrome with One DeletionPHONE SCREEN · Seen Oct 2026
- Search a 2D MatrixPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Attraction Route Without Reusing TrailsPHONE SCREEN · Seen Sep 2026
- Earliest Car for Each PassengerPHONE SCREEN · Seen Sep 2026
- Minimum Stores for a Shopping ListPHONE SCREEN · Seen Sep 2026
Similar questions at other companies
- Classify Password StrengthHackerRank · OA · PHONE SCREEN · ONSITE INTERVIEWHackerRank interview questions
- Highest Bid Campaign MatcherStackAdapt · ONSITE INTERVIEWStackAdapt interview questions
- Route Pattern MatcherGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
- Group AnagramsAmazon Web Services · ONSITE INTERVIEWAmazon Web Services interview questions
- Linked Merchants Within Two HopsStripe · PHONE SCREENStripe interview questions
- Query Log MatchDatadog · PHONE SCREEN · ONSITE INTERVIEWDatadog interview questions
- Dasher Pay with Store Waits and Peak HoursDoorDash · PHONE SCREENDoorDash interview questions
- File System Shell CommandsHarvey · ONSITE INTERVIEWHarvey interview questions
- Fuzzy Word Lookup With One Misspelled LetterMeta · PHONE SCREENMeta interview questions
- Most Frequent Call Path From Function Trace LogsRoblox · PHONE SCREEN · ONSITE INTERVIEWRoblox interview questions