For nums = [1, 2, 3, 1], when can we return true?
Practice this question from Contains Duplicate - Set Pattern Practice Quiz, with options and an explanation.
Question
For nums = [1, 2, 3, 1], when can we return true?
Option A
At the first 1
Option B
At value 2
Option C
At value 3
Option D — Correct answer
At the final 1
Explanation
When the final 1 is read, it already exists in the set.