Python solution without regex

  • 0

    class Solution(object):
    def findWords(self, words):
    :type words: List[str]
    :rtype: List[str]
    def wordTypeByOneRow(word,row):
    for ele in word:
    if ele not in row:
    return False
    return True

        keyboard = ['qwertyuiop', 'asdfghjkl', 'zxcvbnm']
        res = []
        for word in words:
            lowerWord = word.lower()
            for row in keyboard:
                if wordTypeByOneRow(lowerWord, row):
        return res

Log in to reply

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