python sets and diff - simple


  • 0
    S
    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]
                        break
            
            return ans
    

Log in to reply
 

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