Skip to content
Sharp

Collections · interview question

You have a collection of product prices that need frequent updates and occasional max price retrievals. Which collection strategy would be efficient?

Multiple choiceHardchapter-4-curatedpremiumcollectionscollection-performance-basics
Choose one answer
Answer and explanation

Correct answer

A. Use a PriorityQueue to keep prices sorted

Why

A PriorityQueue efficiently supports retrieval of the maximum or minimum element in logarithmic time, making it suitable for collections that require frequent max price checks.

Test yourself on Collections

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

Start free test
All Collections questions →