Using only an array for a data structure, what would be the fastest time complexity in finding duplicate max values in the array?
I am thinking one loop is needed to find the max value and another loop would be needed to find if there are any duplicates. Each loop would have to touch each element once so it would be linear time complexity O(n). Given 2 loops we would have O(n) * O(n) = O(n^2).
Does this sound right or does anyone think it can all be done in one loop to keep the time complexity O(n).
I've looked the problem up, but I see fancy solutions like using a hash table. I need to use an array.