[DAY15]Minimum Absolute Difference in an Array
1 min readOct 18, 2019
Solution 1: Generate all the absolute differences between two elements in the input array. The time complexity would be O(N²).
Solution 2: First of all, we sort the input array. Because the input array is sorted, the closest value would exist in the left side or right side of the element. Hence, we only need to traverse the sorted array once to find the minimum absolute difference.