【LeetCode】500.Keyboard Row_EASY(三)
来源:互联网 发布:关于数据新闻的选题 编辑:程序博客网 时间:2024/05/21 06:22
500.Keyboard Row
Description:
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:
1. You may use one character in the keyboard more than once.
2. You may assume the input string will only contain letters of alphabet.
思路:正则表达式。为了方便,把单词中的字母都转为小写。
代码:
public class Solution { public String[] findWords(String[] words) { ArrayList<String> newWords=new ArrayList<String>(); for(String word:words){ if(word.toLowerCase().matches("[qwertyuiop]*|[asdfghjkl]*|[zxcvbnm]*")){ newWords.add(word); } } return newWords.toArray(new String[newWords.size()]); }}
完成。
0 0
- 【LeetCode】500.Keyboard Row_EASY(三)
- Leetcode-500. Keyboard Row
- 【Leetcode】500. Keyboard Row
- 【LeetCode】500. Keyboard Row
- LeetCode 500. Keyboard Row
- LeetCode 500. Keyboard Row
- leetcode 500. Keyboard Row
- [LeetCode]500. Keyboard Row
- LeetCode | 500. Keyboard Row
- [LeetCode]500. Keyboard Row
- LeetCode 500. Keyboard Row
- 【LeetCode】500. Keyboard Row
- Leetcode 500. Keyboard Row
- LeetCode 500. Keyboard Row
- LeetCode 500. Keyboard Row
- [leetcode]: 500. Keyboard Row
- leetcode 500. Keyboard Row
- [leetcode] 500. Keyboard Row
- Hibernate_面试中最常考察的知识点整合
- PE修复Windows系统密码
- JS_7个JavaScript简写技巧
- rdkafka性能测试小结
- iOS 带渐变背景动画的折线统计图
- 【LeetCode】500.Keyboard Row_EASY(三)
- 读过的最好的 C++ 开源代码
- C++在命名空间中声明类和成员函数
- 工作便签1
- ftp_文件上传Util
- f:Grid
- 微信小程序第三天(布局:栅格布局)
- CodeForces 788B Weird journey
- ubuntu_Improve Power Usage on Ubuntu 12.04 and Prolong Laptop Battery Life