Approach hintTry it first, then revealHide
Insert the values into a hash set one by one; a value that is already present settles the answer. Sorting and comparing neighbours is the O(n log n) alternative with no extra set.
Insert the values into a hash set one by one; a value that is already present settles the answer. Sorting and comparing neighbours is the O(n log n) alternative with no extra set.