• + 0 comments

    Creating a defaultdict makes this one pretty easy.

    ` from collections import defaultdict

    def matchingStrings(stringList, queries): hm = defaultdict(int) for key in stringList: hm[key] += 1 return [hm[key] for key in queries] `