HackerRank içerisinde bulunan “Minimum Absolute Difference in an Array” sorusunun açıklaması ve çözümü. Bu soruda size verilen bir tam sayı dizisi içerisinde, herhangi iki elemanın arasındaki mutlak değer farkının minimum değerini döndürmeniz isteniyor.
► HackerRank – Minimum Absolute Difference in an Array: https://www.hackerrank.com/challenges/minimum-absolute-difference-in-an-array/problem
► Problem açıklaması:
The absolute difference is the positive difference between two values a and b, is written |a – b| or |b – a| and they are equal. If a = 3 and b = 2, |3 – 2| = |2 – 3| = 1. Given an array of integers, find the minimum absolute difference between any two elements in the array.
Function Description
Complete the minimumAbsoluteDifference function in the editor below. It should return an integer that represents the minimum absolute difference between any pair of elements.
Sample Input 0
3
3 -7 0
Sample Output 0
3
Sample Input 2
5
1 -3 71 68 17
Sample Output 2
3