Count Triplets

  • + 1 comment

    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 :)