Let’s say I have an array of n elements(numbers or words), I want to find all the elements which occur more than once in the array. What is the most efficient approach of doing this in terms of performance?
PS: I can sort the array first, but only if that doesn’t affect the total performance much.
Also, though this is mainly php, i would like to know a algorithm or logic that can be implemented on other platforms too.
You can use array_count_values and array_filter
output