Adding frequency of elements of suffix to hash for subarray starting from first index There is no prefix for this sub array
for ( int i = k ; i < n ; i ++ ) m . put ( a [ i ] , m . getOrDefault ( a [ i ] , 0 ) + 1 ) ;