Guest User

Untitled

a guest
Nov 11th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. class Solution(object):
  2. def findWords(self, words):
  3. """
  4. :type words: List[str]
  5. :rtype: List[str]
  6. """
  7. q = set("qwertyuiop")
  8. a = set("asdfghjkl")
  9. z = set("zxcvbnm")
  10. map = {}
  11. for c in q:
  12. map[c] = 0
  13. for c in a:
  14. map[c] = 1
  15. for c in z:
  16. map[c] = 2
  17. res = []
  18. for word in words:
  19. i = -1
  20. for c in word:
  21. if i == -1: i = map.get(c.lower())
  22. if i != map.get(c.lower()):
  23. i = -1
  24. break
  25. if i != -1:
  26. res.append(word)
  27. return res
Add Comment
Please, Sign In to add comment