Group Duplicate Hotel Listings by Normalized Name and City

Last updated: November 29, 2026

Quick Overview

Given hotel listings as (listing_id, name, city) from multiple supply partners, return groups of listing ids that are likely the same property: same city (case and whitespace insensitive) and the same name after lowercasing, stripping punctuation, dropping filler words like "the" and "hotel", and ignoring word order.

Agoda
Coding & Algorithms
Software Engineer
Agoda
November 29, 2026
Software Engineer
Online Assessment
Coding & Algorithms
Easy

0

0

0 solved


Given hotel listings as (listing_id, name, city) from multiple supply partners, return groups of listing ids that are likely the same property: same city (case and whitespace insensitive) and the same name after lowercasing, stripping punctuation, dropping filler words like "the" and "hotel", and ignoring word order.

Agoda aggregates inventory from direct hotel contracts and third-party suppliers, so the same property often arrives several times under slightly different names. This warm-up style problem in an online assessment checks whether you can design a canonical key and use a hash map cleanly, without overcomplicating it.

What the Interviewer Expects
  • Define a deterministic normalization: lowercase, extract alphanumeric tokens, drop stop words, sort tokens
  • Use a composite key of normalized city and normalized name in a hash map
  • Return only groups with two or more listings, in a stable order
  • Run in linear time in the total input length (plus small per-name token sorts)
  • Discuss where exact-key matching breaks down (typos, transliteration)
Key Topics to Cover
hash maps
string normalization
canonical keys
grouping
entity resolution
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 also catch near-duplicates with a single typo, like "Riverside" vs "Riversde"?
  • Listings also carry latitude and longitude; how would you use them to avoid merging two different hotels with the same name in a large city?
  • How would you handle names in Thai or Japanese script alongside romanized versions?
  • If listings arrive as a stream, how do you keep the groups up to date incrementally?
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: a list of (listing_id, name, city). Two listings match when the city matches after trimming and lowercasing, and the name matches after normalization. Normalization: lowercase, keep alphanume...

High-Level Design

Build a canonical key per listing and bucket listings by key in a dictionary. Every listing is touched once; grouping is just reading the buckets back. The key is a tuple (city_key, name_key) so tha...


Submit Your Answer
Markdown supported