Keyboard Row LeetCode solution in Python

1
class Solution:
2
def findWords(self, words: List[str]) -> List[str]:
3
#
4
set1 = {"q", "w", "e", "r", "t", "y", "u", "i", "o", "p"}
5
set2 = {"a", "s", "d", "f", "g", "h", "j", "k", "l"}
6
set3 = {"z", "x", "c", "v", "b", "n", "m"}
7

8
res = []
9
for i in words:
10
wordset = set(i.lower())
11
if (
12
(wordset & set1 == wordset)
13
or (wordset & set2 == wordset)
14
or (wordset & set3 == wordset)
15
):
16
res.append(i)
17
return res

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0