Any O(N^2) time solution gets a Time Limit Exceeded error


I’ve tried iterating through the vector once keeping a map mapping already visited values to the number of times they are seen and checking each value against that, but that gets Time Limit Exceeded too. How does one do this in (O(N) time?