500-Keyboard-Row
Sat 17 May 2025
https://leetcode.com/problems/keyboard-row
import pyutil as pyu
pyu.get_local_pyinfo()
print(pyu.ps2("python-dotenv"))
from typing import List
class Solution:
def findWords(self, words: List[str]) -> List[str]:
ans = []
rows = [set('qwertyuiop'), set('asdfghjkl'), set('zxcvbnm')]
for word in words:
lowerWord = set(word.lower())
if any(lowerWord <= row for row in rows):
ans.append(word)
return ans
new Solution().findWords()
Score: 5
Category: leetcode