It's maybe the best way to solve the problem in python


  • 0
    Q

    class Solution(object):
    def findWords(self, words):
    """
    :type words: List[str]
    :rtype: List[str]
    """
    A=set('QWERTYUIOP')
    B=set('ASDFGHJKL')
    C=set('ZXCVBNM')
    D=[]
    for i in words:
    if set(i.upper()).issubset(A)==True:
    D.append(i)
    elif set(i.upper()).issubset(B)==True:
    D.append(i)
    elif set(i.upper()).issubset(C)==True:
    D.append(i)
    else:
    pass
    return(D)


Log in to reply
 

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