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 guess there is no need to put both A and B into std::map. After all, we have to iterate over one array and perform search in the other array. Therefore, it is sufficient to put only A into a std::map.
Besides, I think hash table (std::unordered_map) is a better choice than binary search tree (std::map) since we only need to retrieve an element as fast as possible rather than retrieve a range, etc.
Beautiful Pairs
You are viewing a single comment's thread. Return to all comments →
I guess there is no need to put both A and B into std::map. After all, we have to iterate over one array and perform search in the other array. Therefore, it is sufficient to put only A into a std::map. Besides, I think hash table (std::unordered_map) is a better choice than binary search tree (std::map) since we only need to retrieve an element as fast as possible rather than retrieve a range, etc.
With the hash table https://www.hackerrank.com/challenges/beautiful-pairs/submissions/code/20992981