Reported June 2026
Agodasorting

Minimum Absolute Difference Pairs

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

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

The Agoda OA reported in June 2026 looks like a pair-finding problem, but it's a sorting problem in disguise. Sort the array, and the closest pair of values has to sit next to each other. That's the whole reduction. If you've got an invite and 48 hours, this is one to nail the first time. StealthCoder is there as a safety net during the live OA if your mind goes blank on the details, but the idea is short enough to hold in your head.

The problem

Given an integer array nums, find every pair of values whose absolute difference is equal to the minimum absolute difference among any two elements in the array.
Return the pairs with each pair written in ascending order. Return the list of pairs sorted by the first value in each pair, then by the second value.

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

Examples
Example 1
nums = [4, 2, 10, 3, 5]
return = [[2,3],[3,4],[4,5]]
After sorting the values as [2,3,4,5,10], the minimum absolute difference is 1. The pairs with that difference are [2,3], [3,4], and [4,5].

Constraints
The source post did not specify numeric constraints.

Reported by candidates. Source: FastPrep

Pattern and pitfall

Sort nums ascending. The minimum absolute difference can only come from adjacent elements, because anything farther apart in sorted order has a gap at least as big. So do one pass to find the smallest adjacent gap, then a second pass collecting every adjacent pair [a, b] with b - a equal to that gap. Sorted order means your output is already ordered by first value, then second, so you don't re-sort. The common pitfall is comparing every pair in a nested loop, which is O(n^2) and risks timing out when the constraints aren't stated. Another trap is duplicates. Two equal values give a gap of 0, and every adjacent duplicate pair then counts. Watch for arrays with fewer than two elements too. If you blank on the two-pass structure in the live OA, StealthCoder can hand you the clean version quickly.

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 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. 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 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 Agoda's OA.

Agoda 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.

Minimum Absolute Difference Pairs FAQ

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

Sort first. After sorting, the smallest difference must be between neighbors, so you only check adjacent elements. Find the minimum gap, then collect every adjacent pair matching it. No nested loops needed, and the output order falls out of the sort.

What time complexity should I aim for?+

O(n log n), dominated by the sort. The two linear passes after that are O(n). A brute force O(n^2) pair check works on small inputs but is risky since the constraints weren't specified in the report. Go with sort plus scan.

How do duplicates change the answer?+

Duplicates make the minimum difference 0. Then every adjacent equal pair is a result, like [3,3]. Your code handles this naturally if you compare adjacent gaps and don't skip equal values. Don't dedupe the array before scanning, or you'll lose valid pairs.

Do I need to sort the output pairs separately?+

No. Since you walk the sorted array left to right, pairs come out ordered by first value, then second. Each pair is also already ascending because you write [nums[i], nums[i+1]]. Just append in order.

How do I prepare for this in 48 hours?+

Write the solution from scratch twice. One pass to find the min gap, one to collect pairs. Then test edge cases: duplicates, negative numbers, two elements, and all-equal arrays. It's a short problem, so speed and clean edge handling matter more than new concepts.

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

OA at Agoda?
Invisible during screen share
Get it