Hello.
i was trying to solve this problem.
Given an array of size N in which every number is between 1 and N, determine if there are any duplicates in it.
Well, what i did is, use an array called present, to flag the elements ie:
for (i = 0; i < N; i++) {
if (!present[i]) {
present[i] = 1;
} else {
/* duplicate */
}
Is there a better way of doing it?