Python Code using set

  • 0

    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)):
    return (res)

Log in to reply

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