You are viewing a single comment's thread. Return to all comments →
D = {} arr = sorted(arr) mini = 10e6 for i in range(len(arr) -1): diff = arr[i+1] - arr[i] if diff < mini: mini = diff D[diff] = [arr[i+1], arr[i]] elif diff == mini: D[diff].extend([arr[i+1], arr[i]]) result = sorted(D[mini]) return result
Seems like cookies are disabled on this browser, please enable them to open this website
Closest Numbers
You are viewing a single comment's thread. Return to all comments →