Question.4
An array of n integers contains values in the range [0, n-1], with exactly one duplicate. The constraints are: cannot modify the array and O(1) extra space. Which approach works within these constraints?
[0, n-1]
Select Answer
Sort the array, then scan for adjacent duplicates
Use a hash set to track seen values
Compare every pair using nested loops (brute force)
Use XOR — XOR all elements and all indices 0 to n-1
0
n-1