500. Keyboard Row
来源:互联网 发布:网络整天不稳定 编辑:程序博客网 时间:2024/06/05 14:12
Given a List of words, return the words that can be typed using letters of alphabet on only one row's of American keyboard like the image below.
Example 1:
Input: ["Hello", "Alaska", "Dad", "Peace"]Output: ["Alaska", "Dad"]
Note:
- You may use one character in the keyboard more than once.
- You may assume the input string will only contain letters of alphabet.
解题思路:这题涉及到集合运算,运用python是最方便的。
class Solution(object): def findWords(self, words): """ :type words: List[str] :rtype: List[str] """ rs = map(set, ['qwertyuiop','asdfghjkl','zxcvbnm']) ans = [] for word in words: wset = set(word.lower()) if any(wset <= rset for rset in rs): ans.append(word) return ans
阅读全文
0 0
- Leetcode-500. Keyboard Row
- 【Leetcode】500. Keyboard Row
- 500. Keyboard Row
- 500. Keyboard Row
- 【LeetCode】500. Keyboard Row
- 500. Keyboard Row
- LeetCode 500. Keyboard Row
- 500. Keyboard Row
- 500. Keyboard Row
- LeetCode 500. Keyboard Row
- 500. Keyboard Row
- 500. Keyboard Row (E)
- 500. Keyboard Row
- 500. Keyboard Row
- leetcode 500. Keyboard Row
- 500. Keyboard Row
- [LeetCode]500. Keyboard Row
- 500. Keyboard Row
- 重新给xAxis.data和series.data赋值 然后myChar.SetOption(option) ,去掉原来的数据
- A
- 常用算法:递归,回溯
- unity3d给子物体添加MeshCollider
- Android知识积累
- 500. Keyboard Row
- Golang教程:(二十一)协程
- lintcode--逆波兰表达式求值
- POJ 2155 Matrix 树状数组
- nginx安装
- 关于电脑连不上WiFi,但可以连上网线的解决办法
- 这几天的总结
- openfire xmpp 通过presence service判断用户是否在线
- 【WebDriver】解决ElementNotVisibleException方法总结