Python Code using set


  • 0
    D

    '''
    class Solution:
    def findWords(self, words):
    """
    :type words: List[str]
    :rtype: List[str]
    """
    row1 = set('qwertyuiopQWERTYUIOP')
    row2 = set('asdfghjklASDFGHJKL')
    row3 = set('zxcvbnmZXCVBNM')
    res= []
    for word in words:
    setword = set(word)
    if(setword.issubset(row1) or setword.issubset(row2) or setword.issubset(row3)):
    res.append(word)
    return (res)
    '''


Log in to reply
 

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