Minimum Difference

Problem Overview

  • Given distinct time-based measurements, find the minimum absolute difference and print all pairs that achieve it.
  • Input: int[] measurements. Output: pairs formatted as "a b" in ascending order; pairs themselves sorted; may return a 2D array per note.
  • Constraints: 2 ≤ n ≤ 1e5; values in [-1e9, 1e9].
  • Real-world context: analyzing gaps between measurements over time.
  • A classic coding interview problem and interview question from Ibm interviews.

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Input Variables
Execution Result: