Sparse Arrays

  • + 0 comments
    • Python 3

    One liner with list comprehensions and no aux/temp variables:

    def matchingStrings(strings, queries):
    
        return [
            sum(int(q == s) for s in strings)
            for q in queries
        ]