Skip to content
LakeBench
ProblemsCommunityPricing
Sign inStart practicing

Diff two versions of a product catalog

Python data engineering interview problem. Difficulty: advanced. Pattern: Dictionaries. About 20 minutes. Part of the Pro drill bank.

A product catalog is published as two versions. Merchandising wants what was added, removed, or changed so they can write a changelog.

Diff two versions of a product catalog.

Requirements

  • Ids only in new are adds.
  • Ids only in old are removes.
  • Ids in both with different payloads are changes.

Constraints

  • old and new: mappings of product id to record.
  • Nested field changes count as a change.

Examples

Input: catalog_diff({'A': {'name': 'a', 'price': 1}}, {'A': {'name': 'a', 'price': 2}, 'B': {'name': 'b', 'price': 3}}) Output: {'added': ['B'], 'removed': [], 'changed': ['A']} This input follows the stated rules and produces this output.

Topics: lakebench, python, data-transformation.

More Python interview questions · All interview problems · Learn data engineering

advanced

Diff two versions of a product catalog

Interview-style drill: Given two snapshots of a product catalog, report which products were added, removed, or changed.

Diff two versions of a product catalog.