Problem statement

https://binarysearch.com/problems/Word-Formation/

Solution

Just interate through words and check counters.

Complexity

It is O(m + n) for time and space.

Code

class Solution:
    def solve(self, words, letters):
        ans = 0
        for w in words:
            if not Counter(w) - Counter(letters):
                ans = max(ans, len(w))
        return ans