scan every substring, use two hash table to store the count value