One Python Solution


  • 0
    H
    class Solution(object):
        def findWords(self, words):
            """
            :type words: List[str]
            :rtype: List[str]
            """
            if words == []:
                return []
    
            l1 = ['q','w','e','r','t','y','u','i','o','p']
            l2 = ['a','s','d','f','g','h','j','k','l']
            l3 = ['z','x','c','v','b','n','m']
            out = []
            for w in words:
                if sum([i in l1 for i in list(w.lower())]) == len(w) or sum([i in l2 for i in list(w.lower())]) == len(w) or sum([i in l3 for i in list(w.lower())]) == len(w):
                    out.append(w)
            return out
    

    Not so quick, hope can be improved.


Log in to reply
 

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