leetcode 500. Keyboard Row
来源:互联网 发布:风凰新闻软件 编辑:程序博客网 时间:2024/05/17 09:21
package com.swjtu.easy.twosum;import java.util.ArrayList;import java.util.HashSet;/** * @author tangmin * @create 2017年2月26日 下午12:11:23 */public class KeyboardRow {public static void main(String[] args) {// TODO Auto-generated method stubString[] words = {"qz", "Hello", "Alaska", "Dad", "Peace"};for (String str: new KeyboardRow().findWords(words))System.out.println(str);}public String[] findWords(String[] words) {String alphabet = "qwertyuiopasdfghjklzxcvbnm";ArrayList<String> reslist = new ArrayList<String>();for(int i= 0;i <words.length; i++) {HashSet<String> set = new HashSet<String>();for (int j=0;j<words[i].length(); j++) {int idx = alphabet.indexOf(words[i].toLowerCase().charAt(j));if(idx<10) {set.add("1");}else if (idx < 19) {set.add("2");}else {set.add("3"); }}if (set.size()==1) { reslist.add(words[i]);}}return (String[])reslist.toArray(new String[reslist.size()]);}}
0 0
- 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
- LeetCode 500. Keyboard Row
- SpringBoot实践
- Ubuntu系统搭建以太坊开发平台过程
- C++类继承
- hibernate的Configuration和配置文件
- POJ1182 食物链 种类并查集(经典)
- leetcode 500. Keyboard Row
- Mac 10.12 之后自带vim从7.3版本升级到7.4版本
- iOS 沙盒目录结构解析
- Unity截屏方法,在Unity中进行截屏。
- leecode 解题总结:284. Peeking Iterator
- SQL执行批处理程序查询信息
- kafka connect简介以及部署
- strcpy()函数详解
- 资料