Marketing wants to know which audience segments overlap before buying against them, so the same visitor is not paid for twice. Membership is appended by several jobs and the same visitor can be written into a segment more than once.
segment_a, segment_b, shared_visitors for every pair sharing at least one visitorsegment_a < segment_b; report each pair once, never both directions and never a self-pairshared_visitors descending, then segment_a, then segment_bsegment_members| segment_id | visitor_id |
|---|---|
| 1 | v1 |
| 1 | v2 |
| 2 | v2 |
| 2 | v3 |
| segment_a | segment_b | shared_visitors |
|---|---|---|
| 1 | 2 | 1 |
segment_members| segment_id | visitor_id |
|---|---|
| 1 | v1 |
| 1 | v1 |
| 2 | v1 |
| 2 | v1 |
| 2 | v1 |
| segment_a | segment_b | shared_visitors |
|---|---|---|
| 1 | 2 | 1 |
Community-reported interview topic. Not an official company question and no affiliation is implied.
Run against the public tests, or submit to score against all of them.