You could use buckets to achieve O(N) + C (with a HUGE C) but at the cost of storage
- Create an array of ints of MAX_INT size called bucket[MAX_INT]
- Loop through input array. If value is x, increment bucket[x]++;
- Loop through input array again. For every x if bucket[x] == 1, add into expected array.
the bucket[] array can be replaced with a better data structure. But it still achieves O(N)