Sum of Mode Frequency of all Subarrays

Revision en1, by bihariforces, 2024-06-14 07:01:32

Mode of an array is the most frequent element, mode frequency is frequency of most frequent element.

For example, $$$[1,3,5,5]$$$ has mode $$$5$$$ and it's frequency is $$$2$$$ so mode frequency of this array is $$$2$$$.

For an array of length $$$N$$$ we need to find sum of mode frequency of all subarrays.

Is there any way to do this better than $$$O(N^2)$$$?

Tags algorithms

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English bihariforces 2024-06-14 07:01:32 384 Initial revision (published)