-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path500.py
More file actions
27 lines (27 loc) · 861 Bytes
/
Copy path500.py
File metadata and controls
27 lines (27 loc) · 861 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
class Solution(object):
def findWords(self, words):
"""
:type words: List[str]
:rtype: List[str]
"""
res = [];
kb = ["QWERTYUIOPqwertyuiop", "ASDFGHJKLasdfghjkl", "ZXCVBNMzxcvbnm"];
for word in words:
tag = 0;
fl = True;
for letter in word:
if letter in kb[0] and (tag == 0 or tag == 1):
tag = 1;
continue;
elif letter in kb[1] and (tag == 0 or tag == 2):
tag = 2;
continue;
elif letter in kb[2] and (tag == 0 or tag == 3):
tag = 3;
continue;
else:
fl = False;
break;
if fl:
res.append(word);
return res;