Magicsheet logo

Find the Most Common Response

Medium
25%
Updated 8/1/2025

Asked by 1 Company

Find the Most Common Response

What is this problem about?

In the Find the Most Common Response interview question, you are given a set of survey data or messages. You need to identify which specific response (a word or a string) appears most frequently. This often involves cleaning the input (removing punctuation, handling case sensitivity) and then counting occurrences.

Why is this asked in interviews?

Meta and other social media companies ask this to test basic Hash Table interview patterns and string processing. It evaluations your ability to handle "unstructured" data and transform it into a structured frequency map. It’s a foundational task for sentiment analysis, trend detection, and basic data analytics.

Algorithmic pattern used

This is a Frequency Counting problem.

  1. Clean the input: Convert to lowercase and remove non-alphanumeric characters.
  2. Split the string into individual response tokens (words).
  3. Use a Hash Map to store the count of each token.
  4. Iterate through the map to find the key with the maximum value.
  5. If there are ties, return any or all depending on the problem's requirement.

Example explanation

Responses: "Yes, No, YES! maybe, no, yes."

  1. Cleaned: "yes no yes maybe no yes"
  2. Counts: {"yes": 3, "no": 2, "maybe": 1}.
  3. Max count is 3. Result: "yes".

Common mistakes candidates make

  • Case Sensitivity: Counting "Yes" and "yes" as different responses.
  • Punctuation: Not removing commas or exclamation marks, leading to "yes!" being a different key than "yes".
  • Inefficient Search: Re-scanning the list multiple times instead of using a single pass with a Hash Map.

Interview preparation tip

Always clarify the rules for "cleaning" data. Should "apple-tree" be one word or two? Should numbers be ignored? Showing that you think about data quality before implementing the logic is a sign of an experienced engineer.

Similar Questions