Minimum Absolute Difference in an Array

  • + 0 comments
    def minimumAbsoluteDifference(arr):
        minimum = 10e10
        Arr = sorted(arr)
        for i in range(1, len(Arr)):
            minimum = min(minimum, abs(Arr[i] - Arr[i-1]))
            if minimum == 0:
                return 0
        return minimum