LeetCode500. Keyboard Row(ArrayL
作者:
Yuu_CX | 来源:发表于
2017-02-13 20:27 被阅读0次public class Solution {
public String[] findWords(String[] words) {
String regex="[qwertyuiop]*|[asdfghjkl]*|[zxcvbnm]*";
String a;
ArrayList<String> list = new ArrayList<>();
for(int i=0;i<words.length;i++){
a = words[i].toLowerCase();
if(a.matches(regex)) list.add(words[i]);
}
return list.toArray(new String[0]);//若直接返回list报错,必须转化下
}
}
本文标题:LeetCode500. Keyboard Row(ArrayL
本文链接:https://www.haomeiwen.com/subject/dautwttx.html
网友评论