Reported September 2026
Stripesorting

Rank Linked Merchants by Weighted Shared Attributes

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 mistake that sinks a first attempt on this Stripe OA, reported in September 2026, is comparing every merchant against every other one. With 100000 merchants, that blows up fast. The problem is really a lookup plus a sort. You score each merchant against the target's attributes, drop the zeros, and order the survivors. Candidates who read it as a graph or pairwise problem burn their time on the wrong thing. If you blank on the scoring loop during the live OA, StealthCoder runs invisibly on your desktop and gives you a working solution as a safety net. The logic is simple once you see it.

The problem

You are given merchant records, attribute weights, and a target merchant ID.
Each row in merchants starts with a unique merchant ID and then contains alternating attribute names and values: [merchantId, name1, value1, name2, value2,...]. Attribute names are unique within one row.
Each entry in attributeWeights has the form attributeName|weight. An attribute contributes its weight to another merchant's link score when that merchant and the target have exactly the same attribute name and value. Attributes without a supplied weight contribute zero.
Exclude the target. A different merchant is linked when its score is positive. Return every linked merchant as merchantId|score, ordered by descending score and then by ascending merchant ID.
When every supplied weight is 1, the result contains exactly the merchants that share at least one weighted attribute with the target.

Function
rankLinkedMerchants(merchants: String[][], attributeWeights: String[], targetMerchantId: String) → String[]

Examples
Example 1
merchants = [["m1","email","a@x","country","US","phone","111"],["m2","email","a@x","country","US","phone","999"],["m3","email","z@x","country","US","phone","111"],["m4","email","a@x","country","CA","phone","111"],["m5","email","z@x","country","CA"]]
attributeWeights = ["email|5","phone|3","country|2"]
targetMerchantId = "m1"
return = ["m4|8","m2|7","m3|5"]
m4 matches email and phone for score 8; m2 matches email and country for 7; m3 matches phone and country for 5. m5 scores zero.
Example 2
merchants = [["target","email","root@x","note","same"],["b","email","root@x"],["a","email","root@x"],["c","note","same"]]
attributeWeights = ["email|4","note|0"]
targetMerchantId = "target"
return = ["a|4","b|4"]
a and b tie and are ordered by ID. Although c matches note, that attribute has weight zero, so c is not linked.
Example 3
merchants = [["solo","region","west"]]
attributeWeights = ["region|10"]
targetMerchantId = "solo"
return = []
The target is excluded and there are no other merchants.

Constraints
1 <= merchants.length <= 100000.
Every merchant row contains a unique nonempty ID followed by at most 20 attribute-name/value pairs.
Merchant IDs, attribute names, and attribute values are printable ASCII strings of length at most 100 and contain no pipe character.
1 <= attributeWeights.length <= 20, and every weighted attribute name appears at most once.
Every weight is an integer from 0 through 1000000.
targetMerchantId identifies exactly one merchant.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick is one pass over the merchants. Build a map from attribute name to weight, and a map from the target's attribute name to its value. For each other merchant, walk its pairs. If the name has a weight, and the value equals the target's value for that name, add the weight. That's at most 20 pairs per row, so the work is linear. Keep only scores above zero, then sort by score descending and ID ascending. The common pitfall is the zero weight case. Example 2 shows a matching attribute with weight 0 must not link a merchant. Another trap is forgetting to exclude the target, or parsing attributeWeights wrong when splitting on the pipe. Sum scores can reach 20 million, which is fine in 32-bit ints but use a long if you want to be safe. Format output as id|score strings. If the sort comparator or parsing trips you up mid-OA, StealthCoder is the hedge that reads the problem and hands you the code.

StealthCoder is the hedge for the one pattern you didn't drill. It runs invisibly during the screen share.

If this hits your live OA

You can drill Rank Linked Merchants by Weighted Shared Attributes 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. If you're reading this with an OA window open, you're who this was built for.

Get StealthCoder

Related leaked OAs

⏵ The honest play

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

Stripe reuses patterns across OAs. If you're reading this with an OA window open, you're who this was built for. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Rank Linked Merchants by Weighted Shared Attributes FAQ

What's the trick to this Stripe merchant ranking problem?+

Don't compare merchants to each other. Compare each one only to the target. Store weights in a map and the target's attributes in a map, then sum matching weights per merchant in one pass. Sort at the end. That's linear work plus an n log n sort.

How hard is this OA really?+

Easy to medium. There's no clever algorithm, just careful parsing and a two-key sort. Most failures come from edge cases like zero weights, excluding the target, and tie ordering by merchant ID. If you handle those, it's a quick solve.

Why does the zero-weight attribute matter?+

A merchant is linked only when its score is positive. An attribute with weight 0 can match exactly and still add nothing. In Example 2, merchant c shares the note value but has no other match, so it gets excluded. Filter on score greater than zero, not on any match.

How should I sort the results?+

Sort by score descending, then by merchant ID ascending. Compare scores first, and only fall back to string comparison on ties. Sort on the numeric score before you format into the id|score string, or you'll end up with string-ordered scores like 10 before 7.

How do I prepare for this in 48 hours?+

Practice parsing delimited strings, building hash maps from them, and writing multi-key comparators. Then do one pass of this exact problem using the three examples as tests. Check the target-only case returning an empty list. That covers nearly everything this problem tests.

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