I have an array say
8 3 5 4 4 4 4 4 3 2 7 11 12 7 7 7 7 1 2
total =17 elements now you are given a range say [2,11] both included ,now you have o find out the element that has occurred the max number of times and the number of times it has occurred
A simple traversing through the array in the range and keeping the track of the each element is one solution but time complexity is O(N) and if we are given N queries time complexity = O(N^2). Any faster algo than this ?
O(n)
? $\endgroup$ – Andy Turner Mar 17 '17 at 11:55