Group Duplicate Business Listings by Normalized Phone Number

Last updated: November 29, 2026

Quick Overview

Given a list of (business_id, raw_phone_string) pairs typed by users and partners in inconsistent formats, return the groups of business ids that share the same normalized US phone number.

Yelp
Coding & Algorithms
Software Engineer
Yelp
November 29, 2026
Software Engineer
Phone Screen
Coding & Algorithms
Easy

0

0

0 solved


Given a list of (business_id, raw_phone_string) pairs typed by users and partners in inconsistent formats, return the groups of business ids that share the same normalized US phone number.

Yelp ingests business data from owners, partners and user edits, so the same restaurant often appears with phone numbers like (415) 555-0100 and +1 415.555.0100. This warm-up checks that you clarify normalization rules before coding and that you reach for a hash map keyed on a canonical form.

What the Interviewer Expects
  • Ask which formats count as the same number (country code, extensions, letters)
  • Normalize to a canonical key and group with a dictionary in one pass
  • Skip or flag numbers that cannot be normalized instead of guessing
  • Return only groups with more than one listing
  • State O(total characters) time
Key Topics to Cover
hashing
string normalization
grouping
data quality
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • How would you handle extensions like x204 or international numbers?
  • What if two different businesses legitimately share a phone number, such as a food hall?
  • How would this run over 200 million listings in a batch job?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements

Input: pairs of (business_id, raw_phone). Two listings are duplicates candidates if their phones normalize to the same 10 digit US number. A leading 1 country code is dropped. Anything that is not...

High-Level Design

Canonicalize, then bucket. Strip every non-digit character, drop a leading 1 when there are 11 digits, and use the resulting string as a dictionary key that maps to a list of business ids. At the en...


Submit Your Answer
Markdown supported

Related Questions