Python 6 lines solution: count 2 empty sets of 3


  • 0
    A
    def findWords(self, words):
            alphabet = ['QWERTYUIOP', 'ASDFGHJKL', 'ZXCVBNM']
            result = []
            for i in words:
                if [set(i.upper())&set(alphabet[0]),set(i.upper())&set(alphabet[1]),set(i.upper())&set(alphabet[2])].count(set([])) == 2:
                    result.append(i)
            return result
    

Log in to reply
 

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