FastPrepMinimum Absolute Difference Pairs
Problems/Minimum Absolute Difference Pairs

Minimum Absolute Difference Pairs

Agoda logoAgodaFULLTIMEONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

You are given an integer array nums. The absolute difference of two numbers is the larger one minus the smaller one. First, find the smallest absolute difference between any two elements of the array. Then sort the array and look only at elements that sit next to each other in sorted order. Keep every such neighbor pair whose absolute difference equals that smallest difference. If a value repeats, each pair of neighboring copies counts as its own pair.

Write each pair in ascending order, with the smaller value first. 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

  • No numeric limits are given for this problem.

More Agoda interview questions

  • Sort Ones, Twos, and Threes In PlacePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Molecular Weight of a Grouped FormulaONSITE INTERVIEW · Seen Oct 2026
  • Minimum Daily Printing LimitONSITE INTERVIEW · Seen Aug 2026
  • Climb Stairs with One, Two, or Three StepsONSITE INTERVIEW · Seen Aug 2026
  • Rank Transform an ArrayONSITE INTERVIEW · Seen Aug 2026
  • Feasibility of Printing Within Given DaysONSITE INTERVIEW · Seen May 2026
  • 3SumONSITE INTERVIEW · Seen May 2026
  • Can Place FlowersPHONE SCREEN · Seen Nov 2026
  • Reverse Words in a StringPHONE SCREEN · Seen Nov 2026
  • Disk Space Window AnalyzerPHONE SCREEN · Seen Sep 2026

Agoda interview experiences

  • Agoda Staff Backend OA Questions: 5 Experiences
All Agoda interview questionsSee Agoda hiring insights
Saved
class Solution {
    public int[][] minimumAbsoluteDifferencePairs(int[] nums) {
      // write your code here
    }
}
Checking account…