Count Triplets

  • + 1 comment

    You're right about O(1) being the average case.

    Python dicts, however, are not based on RB trees but on hash tables with open addressing collision resolution. The probing method in use is double hashing (details here).

    You can lookup the implementation of Python's hash function here. _PyHASH_BITS being defined as 31 for 32bit platforms and 61 for 64bit platforms, all integers dealt with in the current problem have different hash values.