← Questions

Merchant clusters from expiring shared links

0
StripeCodingLast asked Sep 2026

Merchants are linked when they share an attribute such as an address or an email. Over three days you receive reports merchant_id,link_type,duration; a link is active from its report day for duration days, and a later report can renew it.

Each day, build the graph of every merchant seen so far, with an edge between two merchants that share an active link type. A cluster is a connected component with at least two merchants. Each cluster has a pin, a representative merchant chosen by degree (the number of distinct neighbours, ties broken by ID), and pins carry over from day to day as clusters grow, merge and split. Print each day's clusters with their pins, and explain how you recompute components as links expire.

Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding