Stores the frequency of array elements
var freq = Array ( n + 1 ) . fill ( 0 ) ; var i ; for ( i = 0 ; i < n ; ++ i ) { freq [ a [ i ] ] ++ ; } var maxFreqElement = - 2147483648 ; var maxFreqCount = 1 ; for ( i = 1 ; i <= n ; ++ i ) {