Merge Sort Report with a Noisy Comparator
Reported by candidates from Mercor's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
Mercor reported this one in September 2026, and the hook is the comparator that lies on a fixed set of pairs. It looks scary, but it's a plain bottom-up merge sort with two pointers plus some bookkeeping. You simulate the sort exactly as described, flip the result for pairs in wrongPairs, count every service call as one cent, then score the final order. If you've got an OA coming, this is a simulation problem dressed up as an algorithm problem. StealthCoder sits invisibly on screen as a safety net if you blank on the accuracy math during the live assessment.
The problem
You must sort distinct integer-valued objects in descending order by using a comparison service. The service is usually correct but is wrong for a stable set of unordered value pairs. Calling it again on the same pair returns the same result. For deterministic practice, wrongPairs lists the unordered pairs for which the service reverses the true numeric comparison. Every other pair is compared correctly. Run the specified bottom-up merge sort. Start with runs of width one, double the width after every pass, and merge adjacent runs from left to right. During a merge, call the service once whenever both runs still have a front value; place the value reported as greater first. Append a remaining suffix without another service call. Return a string array containing the produced values as decimal strings, followed by accuracyBasisPoints=<value> and costCents=<value>. Accuracy is the fraction of all unordered value pairs that appear in the correct descending relative order, multiplied by 10,000 and rounded to the nearest integer with halves rounded up. A list with fewer than two values has accuracy 10,000. Each comparison-service call costs one cent. Function noisyMergeSortReport(values: int[], wrongPairs: int[][]) → String[] Examples Example 1 values = [4,1,3,2] wrongPairs = [] return = ["4","3","2","1","accuracyBasisPoints=10000","costCents=5"] All five comparisons are correct, so merge sort produces the true descending order and all six unordered pairs are ordered correctly. Example 2 values = [4,1,3,2] wrongPairs = [[4,3]] return = ["3","4","2","1","accuracyBasisPoints=8333","costCents=5"] The comparison between 4 and 3 is reversed. The produced order has one inverted pair out of six, so its rounded accuracy is 8,333 basis points. Example 3 values = [7] wrongPairs = [] return = ["7","accuracyBasisPoints=10000","costCents=0"] A one-value list requires no comparison and is fully accurate by definition. Constraints 1 <= values.length <= 2000. Every value is distinct and lies between -1000000000 and 1000000000. Each row of wrongPairs contains two distinct values from values. No unordered pair appears more than once in wrongPairs.
Reported by candidates. Source: FastPrep
Pattern and pitfall
The trick is to not overthink it. Store wrongPairs in a hash set keyed by the unordered pair (min and max, or a string key). The comparator returns a > b normally, and the opposite if the pair is in the set. Run the bottom-up merge: width 1, 2, 4 and so on, merging adjacent runs left to right with two pointers. Call the comparator only while both runs have fronts, and append leftovers with no call. Count calls for costCents. Accuracy is the tricky part. Count pairs (i<j) in the output where values[i] is less than values[j], since those are inverted for descending order. With n up to 2000 that's about 2 million pairs, so O(n^2) is fine. Accuracy is (total - inverted) * 10000 / total, rounded half up. Use integer math: (2*num*10000 + total) / (2*total). Pitfall: n under 2 gives 10000. StealthCoder is your hedge if the rounding trips you live.
Memorize the pattern. If you can't, run StealthCoder. The proctor sees the IDE. They don't see what's behind it.
You can drill Merge Sort Report with a Noisy Comparator 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. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass Mercor's OA.
Mercor reuses patterns across OAs. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Merge Sort Report with a Noisy Comparator FAQ
How hard is the Mercor noisy comparator problem really?+
Medium at most. The merge sort is standard, and the noise is just a lookup in a set. Most of the risk is in reading the spec carefully: when to call the service, when to append a suffix, and how accuracy is rounded.
What's the trick to the comparator?+
Put each wrong pair in a set using an order-independent key, like the smaller value and larger value joined together. Then compare normally and flip the answer if the pair is in the set. Same pair always gives the same result, so no state is needed.
How do I compute accuracy without floating point errors?+
Count inverted pairs with a double loop over the output. Correct pairs equal total minus inverted, where total is n*(n-1)/2. Then compute round-half-up using integers: (correct*20000 + total) divided by (2*total), using integer division. Return 10000 if n is below 2.
How is costCents counted?+
Increment a counter every time you call the comparator inside a merge, which only happens while both runs still have a front value. Leftover suffix elements are appended with no call. Example 1 with four values gives 5 calls, which matches the sample.
How do I prepare for this in 48 hours?+
Write a bottom-up merge sort from memory with an injectable comparator, then practice a set-based pair lookup. Test on the three examples, especially the [4,3] wrong pair. Check edge cases: one element, odd run counts, and negative values.