Return the maximum difference between frequencies of any two elements such that element with greater frequency is also greater in value .
static int maxdiff ( int arr [ ] , int n ) { Map < Integer , Integer > freq = new HashMap < > ( ) ;