Merchant clusters from expiring shared links
I was asked this
No reports yet. Sign in to say where you were asked it.
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.
No official answer yet. Write yours on the right and run it.
Nothing published yet.
Sign in to submit your code; every attempt is kept here.
