We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
defclosestNumbers(arr):# Write your code herearr.sort()l1=[]mini=abs(arr[0]-arr[1])foriinrange(len(arr)-1):ifabs(arr[i]-arr[i+1])<mini:mini=abs(arr[i]-arr[i+1])foriinrange(len(arr)-1):ifabs(arr[i]-arr[i+1])==mini:l1.append(arr[i])l1.append(arr[i+1])returnl1
Cookie support is required to access HackerRank
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 →