Level: Senior-Level
Round: Phone Screen · Type: Coding · Difficulty: 3/10 · Duration: 60 min · Interviewer: Friendly
Topics: String Manipulation
Location: San Francisco Bay Area
Interview date: 2025-12-15
It was a phone screen tech intervie. The interviewer was friendly and made small talk to ease my nerves.
Here is the coding question:
An online gaming platform needs to automate its content moderation process. You are tasked with developing a system that generates email notifications by summarizing detected rule violations. Given a list of flagged keywords, you need to group them by category and format them into a structured notification body.
You are given three inputs:
detectedWords: A list of strings, where each string is a keyword flagged by the system (e.g., ["scam", "cheat", "bot", "cheat"]).categories: A 2D list of strings, where each inner list [<keyword>, <category>] maps a keyword to its violation category (e.g., [["scam", "Fraud"], ["cheat", "Gameplay"]]).instructions: A 2D list of strings, where each inner list [<category>, <instruction>] maps a category to a corresponding user-facing instruction. The instruction string may have leading or trailing whitespace that needs to be removed (e.g., [["Fraud", " Financial fraud is prohibited. "]]).Your goal is to return a list of lists, where each inner list represents a formatted notification for a specific category and contains two strings:
The output must follow these rules:
If a keyword from detectedWords does not appear in the categories mapping or if no keywords are detected, the output should be an empty list.
Example 1:
Input:
detectedWords = ["scam", "cheat", "bot"], categories = [["scam", "Fraud"], ["cheat", "Gameplay"], ["bot", "Gameplay"]], instructions = [["Fraud", "Financial fraud is prohibited and will result in account suspension"], ["Gameplay", "Unfair gameplay practices detected, please play fairly"]]
Output:
[["Detected Keywords: scam", "Instruction: Financial fraud is prohibited and will result in account suspension"], ["Detected Keywords: bot, cheat", "Instruction: Unfair gameplay practices detected, please play fairly"]]
Explanation: The word "scam" maps to "Fraud", so the first entry lists "scam" and its instruction. Both "bot" and "cheat" map to "Gameplay", so both appear in the second entry, sorted as "bot", "cheat".
Example 2:
Input:
detectedWords = ["spam", "virus", "grief"], categories = [["spam", "Communication"], ["virus", "Security"], ["grief", "Behavior"]], instructions = [["Communication", "Please follow communication guidelines"], ["Security", "Security violation detected"], ["Behavior", "Inappropriate behavior reported"]]
Output: ` [ ["Detected Keywords: spam", "Instruction: Please follow communication guidelines"] ["Detected Keywords: virus", "Instruction: Security violation detected"] ["Detected Keywords: grief", "Instruction: Inappropriate behavior reported"] ]
`
Example 3:
Input:
detectedWords = [], categories = [["test", "Category"]], instructions = [["Category", "Test instruction"]]
Output: []