Given an array of integers, find and print the minimum absolute difference between any two elements in the array. For example, given the array we can create pairs of numbers: and . The absolute differences for these pairs are , and . The minimum absolute difference is .
Complete the minimumAbsoluteDifference function in the editor below. It should return an integer that represents the minimum absolute difference between any pair of elements.
minimumAbsoluteDifference has the following parameter(s):
n: an integer that represents the length of arr
arr: an array of integers
The first line contains a single integer , the size of .
The second line contains space-separated integers .
Print the minimum absolute difference between any two elements in the array.
Sample Input 0
33 -7 0
Sample Output 0
With integers in our array, we have three possible pairs: , , and . The absolute values of the differences between these pairs are as follows:
Notice that if we were to switch the order of the numbers in these pairs, the resulting absolute values would still be the same. The smallest of these possible absolute differences is .