stores the frequency of each element
HashMap < Integer , Integer > count = new HashMap < Integer , Integer > ( ) ; if ( n < 4 ) return 0 ; for ( int i = 0 ; i < n ; i ++ ) { count . put ( arr [ i ] , ( count . get ( arr [ i ] ) == null ? 0 int ) count . get ( arr [ i ] ) ) ) ; }