Did you dream of all the possibilities?
Great solution, but could have directly used counter instead of a defaultdict.
@Algorithmist