LeetCode500.键盘行

class Solution:   
    
    def isAllIn(self, word, strs):
        flag = True
        for s in word:
            if s not in strs:
                flag = False
        return flag
    
    
    def findWords(self, words):
        """
        :type words: List[str]
        :rtype: List[str]
        """
        dict = {1: "QWERTYUIOP", 2: "ASDFGHJKL", 3: "ZXCVBNM"}
        list = []
        for word in words:
            if self.isAllIn(word.upper(), dict[1]) or self.isAllIn(word.upper(),dict[2]) or self.isAllIn(word.upper(), dict[3]):
                 list.append(word)
        return list     

posted @ 2018-05-04 11:29  kkkkkksssss  阅读(115)  评论(0编辑  收藏  举报