Implemented frequency dict and used to solve frequency with mismatches