FastPrepFastPrep
Problem Brief

Minimum Difference

FULLTIMEOA
See Salesforce online assessment and hiring insights

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

1Example 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

Limits and guarantees your solution can rely on.

๐ŸŽ๐ŸŽ
public int[] minimumDifference(int[] measurements) {
  // write your code here
}
Input

measurements

[-1, 3, 6, -5, 0]

Output

[0, 3, 3, 6]

Sign in to submit your solution.