Function to return the updated frequency map for the array passed as argument
function getFrequencyMap ( arr ) { var hashMap = { } ; for ( var i = 0 ; i < arr . length ; i ++ ) { if ( hashMap . hasOwnProperty ( arr [ i ] ) ) { hashMap [ arr [ i ] ] = hashMap [ arr [ i ] ] + 1 ; } else { hashMap [ arr [ i ] ] = 1 ; } } return hashMap ; }