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.
I did this in two pass, once to find the min diff, and one more to add the pairs if diff is min diff. It's because I thought it's wasteful to keep adding the pairs and clearing the res list when we see a smaller diff.
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 →
I did this in two pass, once to find the min diff, and one more to add the pairs if diff is min diff. It's because I thought it's wasteful to keep adding the pairs and clearing the res list when we see a smaller diff.