3-line solution in python using set, map and filter

  • 0
    class Solution(object):
        def findWords(self, words):
            :type words: List[str]
            :rtype: List[str]
            row = map(set, ['qwertyuiop', 'asdfghjkl', 'zxcvbnm'])
            chk = lambda x : sum([set(x.lower()).issubset(r) for r in row])
            return filter(chk, words)

    But it just runs set(x.lower()) 3 times for every word, any good ideas?

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.