3rd way to find a duplicate
Two common ways to detect duplicates in an array:

1) sort first, time complexity O (n log n), space complexity O (1)

2) hash set, time complexity O (n), space complexity O (n)

Is there a 3rd way to detect a duplicate?

Please do not answer brute force.
3rd way to find a duplicate
===

Two common ways to detect duplicates in an array:

1) sort first, time complexity O (n log n), space complexity O (1)

2) hash set, time complexity O (n), space complexity O (n)

Is there a 3rd way to detect a duplicate?

Please do not answer brute force.