Minimum Difference
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' elements ordered ascending. e.g., if a < b, the pair is a b. The values should have a single space between them.
Complete the function minimumDifference in the editor.
minimumDifference has the following parameter:
int measurements[n]: an array of integers
Returns
NONE
(NOTE: NONE is specified by the orignal source. BUT, we wouldnt be able to upload the question if it returns nothing, so we made it return a 2D int arr instead :) π₯ By spike, Dec 2024 π
Prints
Print the distinct pairs of measurements that have the minimum absolute difference, displayed in ascending order, with each pair separated by one space on a single line
π¦₯ Thank spike for the 1011st time! π
1Example 1
2Example 2
3Example 3
Constraints
Limits and guarantees your solution can rely on.
- 2 β€ n β€ 10^5
- -10^9 β€ measurements[i] β€ 10^9