Description
Solutions
Minimum Difference
πŸ”₯ FULLTIME

Given a set of distinct measurements taken at different times, find the minimum possible difference between any two measurements. Print all pairs of measurements that have this minimum difference in ascending order, with the pairs' difference in ascending order, e.g., if a < b, the pair elements ordered ascending, e.g., if a < b, the pair is a b. The values should have a single space between them.

Function Description

Complete the function minimumDifference in the editor.

minimumDifference has the following parameter:

  1. int measurements[n]: an array of integers

Example 1:

Input:  measurements = [-1, 3, 6, -5, 0]
Output: [0, 3, 3, 6]
Explanation:

The minimum absolute difference is 3, and the pairs with that difference are (3,6) and (0,3). When printing element pairs (i,j), they should be ordered ascending first by i and then by j.

Constraints:
    🍎🍎
Thumbnail 0
Testcase

Result
Case 1

input:

output: