You are viewing a single comment's thread. Return to all comments →
Python3 solution All test cases passed
def closestNumbers(arr): sorted_arr = sorted(arr) diff = [] for i in range(len(sorted_arr) - 1): diff.append(sorted_arr[i+1] - sorted_arr[i]) value = min(diff) result = [] for i in range(len(sorted_arr) - 1): if (sorted_arr[i+1] - sorted_arr[i]) == value: result.append(sorted_arr[i]) result.append(sorted_arr[i+1]) 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 →
Python3 solution All test cases passed