If you are allowed to use C++, a call to std::sort
followed by a call to std::unique
will give you the answer. The time complexity is O(N log N) for the sort and O(N) for the unique traversal.
And if C++ is off the table there isn't anything that keeps these same algorithms from being written in C.