FastPrepGroup Linked Merchant Records
Problems/Group Linked Merchant Records

Group Linked Merchant Records

Stripe logoStripe● MediumFULLTIMEINTERNPHONE SCREEN
QuestionFunctionExamplesConstraints

Problem statement

Source note: The source preserves the linked-merchant objective but omits the original schema and multipart rules. The judged core task matches the visible source at about 82%.

Special thanks: 🌷 A special thank you to a lovely, amazing fren for sharing that this question appeared again on October 23, 2026! ദ്ദി ˉ͈̀꒳ˉ͈́ )✧ 💜

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.

More Stripe problems

  • Portfolio Valuation, Part 1PHONE SCREEN · Seen Nov 2026
  • Chat Billing CalculationOA · Seen Nov 2026
  • Deployment Window SchedulerOA · Seen Nov 2026
All Stripe interview questionsSee Stripe hiring insights
Saved
class Solution {
    public List<List<String>> linkedMerchantGroups(String[][] records) {
        // Write your code here
    }
}
Checking account…