python sets and diff - simple

  • 0
    class Solution(object):
        def findWords(self, words):
            :type words: List[str]
            :rtype: List[str]
            rows,ans = [set('qwertyuiop'), set('asdfghjkl'), set('zxcvbnm')], []
            for w in words:
                for r in rows:
                    if set(w.lower()) - r == set():
                        ans += [w]
            return ans

Log in to reply

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