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.
No need to keep adding and deleting to the result array. First the get the abs min difference.
Then loop through the original array once again to figure out the pairs matching this diff. Much better then to do lots of copy and deletes.
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 →
No need to keep adding and deleting to the result array. First the get the abs min difference. Then loop through the original array once again to figure out the pairs matching this diff. Much better then to do lots of copy and deletes.