Solutions for Minimum Differences

    • @admin
    • @admin, submitted in Python 3, achived 100% score
    def solve(arr):
        min_abs = min((abs(arr[i] - arr[i-1]) for i in range(1, len(arr))))
        s = set()
        for x in arr:
            if x in s:
                return 0
            for d in range(1, min_abs):
                if x + d in s or x - d in s:
                    min_abs = d
                    break
            s.add(x)
        return min_abs