Return Words Present in Exactly One Message

Read the full interview experience this question came from →

Quick Overview

Find words appearing in exactly one of two messages using set symmetric difference while clarifying tokenization and case rules.

Return Words Present in Exactly One Message

Company: Discord

Role: Data Scientist

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

## Return Words Present in Exactly One Message Implement `unique_string(msg1, msg2)`. Given two message strings, return a list of words that appear in exactly one message: the symmetric difference of the messages' word sets. Repeated occurrences of a word within one message do not produce repeated words in the result. A word found in both messages is excluded. The exercise does not prescribe the order of the returned list, so different permutations of the same words are valid. ### Clarifications Agree on what counts as a word and whether comparison is case-sensitive before implementing. The prompt does not supply punctuation, tokenization, or case-normalization rules. Apply the agreed convention consistently to both messages. ```hint Consider membership before frequency The requested distinction depends on which messages contain a word. ``` ### What a Strong Answer Covers - Represents each message's distinct words under the same tokenization and case convention. - Includes words belonging to only one message and excludes words shared by both. - Handles repeated words, identical messages, and an empty message. - Returns each qualifying word once and recognizes that result ordering is unrestricted. ### Follow-up Questions - What happens when the two messages contain the same word several times each? - Which tokenization and case rules would you clarify for punctuation or mixed-case text?

Overview: Find words appearing in exactly one of two messages using set symmetric difference while clarifying tokenization and case rules.

Read the full Discord Data Scientist interview experience this question came from

|Home/Coding & Algorithms/Discord
Discord logo
Discord
Sep 26, 2026
mediumData ScientistTechnical ScreenCoding & Algorithms
0
0

Return Words Present in Exactly One Message

Implement unique_string(msg1, msg2). Given two message strings, return a list of words that appear in exactly one message: the symmetric difference of the messages' word sets.

Repeated occurrences of a word within one message do not produce repeated words in the result. A word found in both messages is excluded. The exercise does not prescribe the order of the returned list, so different permutations of the same words are valid.

Clarifications

Agree on what counts as a word and whether comparison is case-sensitive before implementing. The prompt does not supply punctuation, tokenization, or case-normalization rules. Apply the agreed convention consistently to both messages.

What a Strong Answer Covers Guidance

  • Represents each message's distinct words under the same tokenization and case convention.
  • Includes words belonging to only one message and excludes words shared by both.
  • Handles repeated words, identical messages, and an empty message.
  • Returns each qualifying word once and recognizes that result ordering is unrestricted.

Follow-up Questions Guidance

  • What happens when the two messages contain the same word several times each?
  • Which tokenization and case rules would you clarify for punctuation or mixed-case text?

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...