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.
Your time may not be too awful, but your space usage is insane. Your complexity isn't linear though: No matter what you're doing, you have to check every number in the input array at least once for a match, so that's O(n) operations of that check, no matter how it's implemented.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Pairs
You are viewing a single comment's thread. Return to all comments →
Your time may not be too awful, but your space usage is insane. Your complexity isn't linear though: No matter what you're doing, you have to check every number in the input array at least once for a match, so that's O(n) operations of that check, no matter how it's implemented.