title: Fastest way of finding number of distinct elements in an array
body: <p>I have a square matrix containing integers (not necessarily distinct). I need the fastest way to find the number of distinct elements in it. I tried to store the integers in a 1D array, sorted it and then found the number of distinct elements...but apparently, it is not fast enough. Could you suggest a better and faster procedure in C language?</p>