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
Coding & Algorithms
Software Engineer
Rakuten
November 29, 2026
Software Engineer
Online Assessment
Coding & Algorithms
Easy

0

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
hash maps
normalization
string cleaning
grouping
catalog deduplication
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 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 Problems
Sample 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...


Submit Your Answer
Markdown supported

Related Questions