Skip to content
Sharp

Collections · interview question

Why do teams use a HashSet over a List when storing items in production code?

Multiple choiceMediumchapter-4-curatedpremiumcollectionschoosing-the-right-collection
Choose one answer
Answer and explanation

Correct answer

B. Faster lookups

Why

HashSet provides constant time complexity for add, remove, and contains operations. Lists typically have linear time complexity for these operations, especially when checking for duplicates.

Test yourself on Collections

A free test with instant, explained results. No account needed.

Start free test
All Collections questions →