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.
You need to understand how a hashmap internally works, especially in case of collisions.
In most cases, the hashmap maps to a list (or another hashmap!) of values that fall under the same keys. Collisions are rare for small data-sets. And in an EXTREAMLY RARE case, where ALL your values fall under the same key, will the hashmap map every item to the same key, and thus in a list implementation of collision handling, it would be O(N).
Hope that helps. You can read more about dictionaries/hashmap to understand better :)
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 →
You need to understand how a hashmap internally works, especially in case of collisions.
In most cases, the hashmap maps to a list (or another hashmap!) of values that fall under the same keys. Collisions are rare for small data-sets. And in an EXTREAMLY RARE case, where ALL your values fall under the same key, will the hashmap map every item to the same key, and thus in a list implementation of collision handling, it would be O(N).
Hope that helps. You can read more about dictionaries/hashmap to understand better :)