Keyboard Row
来源:互联网 发布:包租婆软件电话 编辑:程序博客网 时间:2024/05/17 04:10
class Solution(object):
def findWords(self, words):
"""
:type words: List[str]
:rtype: List[str]
"""
rows = [set(['q', 'w', 'e', 'r', 't', 'y','u', 'i', 'o', 'p']),
set(['a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l']),
set(['z', 'x', 'c', 'v', 'b' ,'n', 'm'])]
result = []
for word in words:
k = 0
for i in xrange(len(rows)):
if word[0].lower() in rows[i]:
k = i
break
for c in word:
if c.lower() not in rows[k]:
break
else:
result.append(word)
return result
def findWords(self, words):
"""
:type words: List[str]
:rtype: List[str]
"""
rows = [set(['q', 'w', 'e', 'r', 't', 'y','u', 'i', 'o', 'p']),
set(['a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l']),
set(['z', 'x', 'c', 'v', 'b' ,'n', 'm'])]
result = []
for word in words:
k = 0
for i in xrange(len(rows)):
if word[0].lower() in rows[i]:
k = i
break
for c in word:
if c.lower() not in rows[k]:
break
else:
result.append(word)
return result
阅读全文
0 0
- Keyboard Row
- Keyboard Row
- Keyboard Row
- Keyboard Row
- Keyboard Row
- Keyboard Row
- Keyboard Row
- Keyboard Row
- Keyboard Row
- Keyboard Row
- Keyboard Row
- Leetcode-500. Keyboard Row
- 【Leetcode】500. Keyboard Row
- 500. Keyboard Row
- leetcode-500-Keyboard Row
- 500. Keyboard Row
- 【LeetCode】500. Keyboard Row
- 500. Keyboard Row
- leetcode 532. K-diff Pairs in an Array
- 线程池
- 小程序开发之坑一 -- ios不显示tabBar的文字
- java基础二
- Android Studio Error:Failed to resolve: com.android.support:appcompat-v7:25.1.0
- Keyboard Row
- Web自动化之Headless Chrome概览
- redis-压缩列表
- java基础--多线程
- 高并发的核心技术-幂等的实现方案
- 全文检索lucene
- iOS 文件上传 post数据
- 硅咪/硅麦和驻极体MIC在蓝牙耳机方面的应用
- Web自动化之Headless Chrome开发工具库