You are viewing a single comment's thread. Return to all comments →
Python
def closestNumbers(arr): arr = sorted(arr) pair = [(arr[i],arr[i+1], abs(arr[i]-arr[i+1])) for i in range(len(arr)-1)] min1 = min([i[2] for i in pair]) result = [] for i,j,k in pair: if k == min1: result = result + [i,j] 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 →
Python