Reported September 2026
Akuna Capitalsorting

Minimum Absolute Difference Pairs

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

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

Akuna Capital sent this one out in September 2026, and it looks scarier than it is. The wording about API latencies and sorted pairs hides a classic: sort the array, then the closest pairs are always neighbors. If you've got an OA invite and 48 hours, this is the kind of problem you want to see. It's an array and sorting question with one pass of logic. StealthCoder sits in the background as a safety net if your mind goes blank mid-assessment, but the idea is small enough to hold in your head.

The problem

You are given an array latencies of n distinct integers representing API response times.
Your objective is to identify all pairs of response times such that:
The absolute difference between the two values is the smallest possible among all pairs in the array.
Within each pair, the first value is smaller than the second.
The final list of pairs is sorted in ascending order based on the values.
Return all such pairs.

Function
minimumAbsoluteDifferencePairs(latencies: int[]) → int[][]

Examples
Example 1
latencies = [6, 2, 4, 10]
return = [[2, 4], [4, 6]]
Input: n = 4, latencies = [6, 2, 4, 10]
Output: [[2, 4], [4, 6]]
Explanation: The minimal absolute difference is 2, and the pairs with that difference are (2,4) and (4,6). Within the pairs, the elements are ordered, and then the pairs themselves are in ascending order.
Example 2
latencies = [4, -2, -1, 3]
return = [[-2, -1], [3, 4]]
Input: n = 4, latencies = [4, -2, -1, 3]
Output: [[-2, -1], [3, 4]]
The minimal absolute difference is 1, and the pairs with that difference are (-2, -1) and (3, 4).

Constraints
2 ≤ n ≤ 10^5
-2 × 10^6 ≤ latencies[i] ≤ 2 × 10^6
The latencies array contains no duplicate elements.
Test Case Input FormatThe first line contains an integer n, the size of the latencies array.
Each of the next n lines contains an integer, latencies[i].

Reported by candidates. Source: FastPrep

Pattern and pitfall

What it really reduces to: sort, then scan adjacent elements. The minimum absolute difference between any two values in a set must occur between neighbors in sorted order, because anything wider has a value sitting between them that gives a smaller gap. So sort latencies, compute the smallest adjacent gap, then collect every adjacent pair whose gap equals it. Sorting also gives you the required output order for free, since pairs come out ascending with the smaller value first. Complexity is O(n log n) time, which is fine for n up to 10^5. Common pitfalls: comparing all pairs in O(n^2), which times out, and forgetting that the minimum must be known before collecting pairs. You can do it in two passes, or reset the list whenever you find a smaller gap. Negatives are fine, and distinct values mean no zero gaps. If you freeze on the live OA, StealthCoder is the hedge that gets you the sorted-neighbors solution fast.

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 Minimum Absolute Difference Pairs 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

⏵ Practice the LeetCode equivalent

This OA pattern shows up on LeetCode as minimum absolute difference. If you have time before the OA, drill that.

⏵ The honest play

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

Akuna Capital 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.

Minimum Absolute Difference Pairs FAQ

What's the trick in Minimum Absolute Difference Pairs?+

Sort first. After sorting, the smallest difference always sits between two adjacent elements. So you only compare neighbors, find the minimum gap, and collect every adjacent pair with that gap. No nested loops needed.

How hard is this problem really?+

Easy. It's one sort and one or two linear scans. The hard part is spotting that you don't need all pairs. If you see that, the code is about ten lines in most languages.

Why does the brute force fail here?+

With n up to 10^5, checking every pair is about 5 billion comparisons. That will time out. Sorting costs O(n log n) and the neighbor scan is O(n), which fits comfortably.

Do I need to sort the output pairs separately?+

No. If you sort the input and walk it left to right, pairs are emitted in ascending order and each pair already has the smaller value first. Just append [a[i], a[i+1]] as you go.

How should I prepare for this in 48 hours?+

Practice the sort-then-scan-neighbors pattern on a few array problems. Know how to track a running minimum and reset your result list when you find a smaller one. Also check your edge cases: negatives, n equals 2, and several tied pairs.

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

OA at Akuna Capital?
Invisible during screen share
Get it