Part 1 – Direct links: Given a target merchant, return every merchant that shares at least one identical attribute value with it.
Part 2 – Confidence scores: Assign weights to matching fields and return merchants whose total matching score reaches the required threshold.
Part 3 – Indirect links: Return merchants directly linked to the target and merchants linked through one directly linked merchant.
This problem combines attribute-based matching with graph traversal. In the first part, an inverted index or hash map can quickly return merchants that share at least one identical attribute value with the target. In the second part, matching becomes a weighted scoring problem, where each field contributes to a total confidence score and candidates are filtered by a threshold. In the third part, the task shifts to a two-hop neighborhood query: collect merchants directly linked to the target, then expand one more step through those direct neighbors. A practical solution typically uses hash maps, sets for deduplication, and BFS-style expansion when indirect links are involved.