What is the time complexity of finding an element in a hash map?

What is the time complexity of finding an element in a hash map?

Approach: Specify average vs worst-case.

Average case is O(1). Worst case is O(n) if all elements collide into the same bucket.

Follow-up: How can Java 8+ optimize the O(n) worst case?

Key concepts: hashing, collisions.