Suppose we have an array in the size of n, with values range from 0 to n-1.
A function that validates that there are no duplications of values is needed, without using another array.
Prototype: bool UniqueValues(unsigned arr[], size_t n);
This is an algorithm question for job interviews, please don’t suggest using built-in std functions.
Traverse the array and for each element, swap arr[i] with arr in the index of arr[i]( e.g, if arr[1]=2, swap it with arr[2], so arr[2]=2).
The indication whether the value is duplicated is that arr[ arr[i] ] == arr[i]. (found 2 somewhere when there is already 2 at arr[2]).