PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Microsoft

Find pairs with the minimum absolute difference

Last updated: Mar 29, 2026

Quick Overview

This question evaluates array manipulation, sorting-based reasoning, and the ability to generate ordered value pairs that reflect minimum absolute differences while handling ordering and duplicates.

  • medium
  • Microsoft
  • Coding & Algorithms
  • Machine Learning Engineer

Find pairs with the minimum absolute difference

Company: Microsoft

Role: Machine Learning Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

Given an integer array (not necessarily sorted), find the minimum absolute difference between any two distinct elements. Return all pairs of values that achieve this minimum difference. Requirements: - Each pair should be ordered as [smaller, larger]. - Return pairs in ascending order by their first element (and then second if needed). Example: Input: [-1, -2, -4, -5, 7, 10] Output: [[-5, -4], [-2, -1]] Explanation: The minimum difference is 1, achieved by (-5, -4) and (-2, -1).

Quick Answer: This question evaluates array manipulation, sorting-based reasoning, and the ability to generate ordered value pairs that reflect minimum absolute differences while handling ordering and duplicates.

Related Interview Questions

  • Return Top K Open Businesses - Microsoft (hard)
  • Implement Memory Allocation and In-Memory Records - Microsoft (medium)
  • Implement K-Means and Detect Divisible Subarrays - Microsoft (medium)
  • Sort Three Categories In Place - Microsoft (medium)
  • Retain Top K Elements - Microsoft (medium)
Microsoft logo
Microsoft
Feb 9, 2026, 12:00 AM
Machine Learning Engineer
Technical Screen
Coding & Algorithms
3
0

Given an integer array (not necessarily sorted), find the minimum absolute difference between any two distinct elements. Return all pairs of values that achieve this minimum difference.

Requirements:

  • Each pair should be ordered as [smaller, larger].
  • Return pairs in ascending order by their first element (and then second if needed).

Example: Input: [-1, -2, -4, -5, 7, 10] Output: [[-5, -4], [-2, -1]] Explanation: The minimum difference is 1, achieved by (-5, -4) and (-2, -1).

Submit Your Answer

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Microsoft•More Machine Learning Engineer•Microsoft Machine Learning Engineer•Microsoft Coding & Algorithms•Machine Learning Engineer Coding & Algorithms
PracHub

Master your tech interviews with 8,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.