Hi i\'m really glad to know this site to ask question. I have a problem that i made an array. And then i want to check matching values in the array. For example,
It depends on whether there are bounds on the size of the int's that can be on your array.
If you can be sure (and check) that all elements in your array are limited to a relatively small range (say, between say 0 and 255), you can use a separate array of size MAXVAL-MINVAL to keep track of where in the array each element first appears. If this is the case, you can quickly check in O(n) (where n is the size of your array) whether (and even where) there are duplicates.
It might look like something like this (caveat: I haven't checked or even compiled this code)
#define COUNTOF(x) ( sizeof(x) / sizeof((x)[0]) )
int i, flags[MAXVAL-MINVAL];
for(i=0; i