Stores the frequencies of array elements
HashMap < Integer , Integer > count = new HashMap < Integer , Integer > ( ) ; for ( int h : arr ) { if ( count . containsKey ( h ) ) count . put ( h , count . get ( h ) + 1 ) ; else count . put ( h , 1 ) ; }