Group Duplicate Ichiba Listings by Normalized Barcode
Last updated: November 29, 2026
Quick Overview
Given merchant listings as (listing_id, barcode string), where barcodes may contain hyphens or spaces and may be 12-digit UPC or 13-digit JAN/EAN codes, return groups of listing ids that refer to the same product. Ignore barcodes that do not normalize to 13 digits.
Rakuten
November 29, 20260
0
0 solved
Given merchant listings as (listing_id, barcode string), where barcodes may contain hyphens or spaces and may be 12-digit UPC or 13-digit JAN/EAN codes, return groups of listing ids that refer to the same product. Ignore barcodes that do not normalize to 13 digits.
Rakuten Ichiba is a marketplace where tens of thousands of independent shops list the same product under their own titles, so catalog matching is a real problem. This online assessment style question checks clean hashing, a sensible canonical key, and careful handling of messy input.
What the Interviewer Expects
- Define a canonical key before grouping
- Convert 12-digit UPC to 13-digit form by left padding with zero
- Skip invalid codes instead of crashing
- Return deterministic, sorted output
- Explain O(total characters) complexity
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- How would you also validate the check digit?
- Two shops use different barcodes for the same item in different pack sizes. How would you detect near-duplicates?
- How would you run this across 300 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 ProblemsSample Answer
Requirements
Input is a list of (listing_id, code). Strip everything that is not a digit. JAN codes used in Japan are EAN-13; a 12-digit UPC-A becomes EAN-13 by prefixing 0. Anything that is not 13 digits afte...
High-Level Design
This is grouping by a derived key. One pass builds normalized_code -> [listing_ids] in a dictionary, then a filter keeps groups of size at least two. The only real design choice is the normalization...