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.
Have a look at the various solutions already posted in this forum. It can be done in either O(N) - arguably (depends on the implementation of maps/hashmaps) - but definitely in O(NlogN).
You're doing various repeating passes through the array when only one is necessary.
Regards.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Count Triplets
You are viewing a single comment's thread. Return to all comments →
Have a look at the various solutions already posted in this forum. It can be done in either O(N) - arguably (depends on the implementation of maps/hashmaps) - but definitely in O(NlogN). You're doing various repeating passes through the array when only one is necessary. Regards.