Function to return the updated frequency map for the array passed as argument
static Dictionary < int , int > getFrequencyMap ( int [ ] arr ) { Dictionary < int , int > hashMap = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < arr . Length ; i ++ ) { if ( hashMap . ContainsKey ( arr [ i ] ) ) { hashMap [ arr [ i ] ] = hashMap [ arr [ i ] ] + 1 ; } else { hashMap . Add ( arr [ i ] , 1 ) ; } } return hashMap ; }