class Solution:
def findWords(self, words: List[str]) -> List[str]:
ans = []
rowIdx = "12210111011122000010020202"
for word in words:
idx = rowIdx[ord(word[0].lower()) - ord('a')]
if all(rowIdx[ord(ch.lower()) - ord('a')] == idx for ch in word):
ans.append(word)
return ans
键盘行python代码
最新推荐文章于 2025-12-26 12:25:29 发布
本文介绍了一种名为Solution的类中findWords方法,用于在给定单词列表中查找全为同一字母的单词。通过rowIdx字符串按字母顺序定位每个单词的索引,有效筛选符合条件的单词。

330

被折叠的 条评论
为什么被折叠?



