Simple Python AC Solution


  • 0
    D
    class Solution(object):
        def findWords(self, words):
            row1 = 'qwertyuiop'
            row2 = 'asdfghjkl'
            row3 = 'zxcvbnm'
            
            res = []
            for word in words:
                if self.contains(word,row1) or self.contains(word,row2) or self.contains(word,row3):
                    res.append(word)
            return res
            
            
        def contains(self,word,row):
            for char in word.lower():
                if not char in row:
                    return False
            return True
    

Log in to reply
 

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