Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution(object):
- def findWords(self, words):
- """
- :type words: List[str]
- :rtype: List[str]
- """
- q = set("qwertyuiop")
- a = set("asdfghjkl")
- z = set("zxcvbnm")
- map = {}
- for c in q:
- map[c] = 0
- for c in a:
- map[c] = 1
- for c in z:
- map[c] = 2
- res = []
- for word in words:
- i = -1
- for c in word:
- if i == -1: i = map.get(c.lower())
- if i != map.get(c.lower()):
- i = -1
- break
- if i != -1:
- res.append(word)
- return res
Add Comment
Please, Sign In to add comment