Why does a set help here?
Practice this question from Contains Duplicate - Set Pattern Practice Quiz, with options and an explanation.
Question
Why does a set help here?
Option A — Correct answer
It gives average O(1) membership checks
Option B
It sorts values automatically
Option C
It stores values in descending order
Option D
It prevents all duplicates from existing
Explanation
A set answers whether a value has been seen before in average O(1).