Reported July 2026
Stripeunion find

Group Linked Merchant Records

Reported by candidates from Stripe's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Stripe OA. Under 2s to a working solution.
Founder's read

The Stripe OA reported in July 2026 looks like a string-parsing chore, but one wrong assumption about which fields count will quietly fail half the hidden tests. Group Linked Merchant Records hands you flat key-value rows and asks for connected groups of merchants. It's a hash-table plus union-find problem wearing a data-cleaning costume. If you're taking this OA in the next couple of days, learn the shape now. StealthCoder sits invisibly on your screen as a safety net if you blank mid-assessment, but the pattern below is short enough to carry in your head.

The problem

You are given merchant dictionaries serialized as records. Each row contains alternating key and value strings: [key1, value1, key2, value2,...]. Every row contains exactly one non-empty merchant_id. A row may also contain the identity fields email, phone, and address, plus arbitrary additional fields.
Two records are directly linked when they share the same non-empty value for at least one identity field with the same key. Merchant groups are the transitive closure of those direct links. Additional fields are valid input but never establish links.
Return every connected group as its merchant IDs sorted lexicographically. Sort the groups lexicographically by their complete sorted ID lists.

Function
linkedMerchantGroups(records: String[][]) → List<List<String>>

Examples
Example 1
records = [["merchant_id","m1","email","a@x.com"],["merchant_id","m2","email","a@x.com","phone","222"],["merchant_id","m3","phone","222"],["merchant_id","m4","address","4 Main"]]
return = [["m1","m2","m3"],["m4"]]
m1 links to m2 by email, and m2 links to m3 by phone, so transitivity joins all three.
Example 2
records = [["merchant_id","b","note","same"],["merchant_id","a","note","same"],["merchant_id","c","email","c@x.com"]]
return = [["a"],["b"],["c"]]
The shared extra field note does not establish a link.

Constraints
1 <= records.length <= 200000
Each row contains between 1 and 20 key-value pairs.
Keys and values are printable-ASCII strings of length at most 200.
Every merchant_id is non-empty and unique.
Within a record, each of merchant_id, email, phone, and address appears at most once.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick: treat each merchant as a node and union nodes that share an identity value. Build a hash map keyed by the pair (field name, value), only for email, phone, and address. First time you see a key, store the merchant index. Next time, union with the stored one. Then bucket merchants by root, sort each bucket's IDs, and sort the groups by their full lists. The edge case that breaks naive solutions is the extra fields. Example 2 shares note=same across two records and they must stay separate. Also skip empty values, and never mix keys, so an email equal to a phone string is not a link. Parse rows by stepping two at a time, since merchant_id can sit anywhere. With 200000 records, avoid pairwise comparison. If you freeze on the grouping logic, StealthCoder can hand you the union-find skeleton live.

If this hits your live OA and you blank, StealthCoder solves it in seconds, invisible to the proctor.

If this hits your live OA

You can drill Group Linked Merchant Records cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it.

Get StealthCoder

Related leaked OAs

⏵ Practice the LeetCode equivalent

This OA pattern shows up on LeetCode as accounts merge. If you have time before the OA, drill that.

⏵ The honest play

You've seen the question. Make sure you actually pass Stripe's OA.

Stripe reuses patterns across OAs. Built by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Group Linked Merchant Records FAQ

What's the core trick in Group Linked Merchant Records?+

Union-find over merchants, driven by a hash map. Key the map on (field, value) for email, phone, and address only. When a key repeats, union the two merchants. Group by root at the end, then sort IDs inside groups and groups themselves.

Why does a naive solution fail?+

Usually it treats every field as an identity field, so shared extras like note link merchants wrongly. Other misses are linking on empty strings, or matching an email value against a phone value because the key wasn't included in the map key.

Can I use DFS instead of union-find?+

Yes. Build an adjacency list through the same (field, value) map, then run iterative DFS or BFS per component. Go iterative, since 200000 records can overflow recursion depth. Union-find is usually shorter and less error-prone here.

How should I handle the sorting requirement?+

Sort each group's merchant IDs as strings, lexicographically. Then sort the list of groups by comparing their sorted ID lists element by element. Don't sort by group size or by first-seen order. Example 2 shows singletons ordered a, b, c.

How do I prep for this in 48 hours?+

Write union-find with path compression from memory once. Then code this problem end to end: parse pairs, build the map, union, bucket, sort. Test on both examples plus an empty-value row and a shared extra field. That covers the traps.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Stripe.

OA at Stripe?
Invisible during screen share
Get it