public class Solution
{
public string[] FindWords(string[] words)
{
var list1 = new List<char>();
var list2 = new List<char>();
var list3 = new List<char>(); list1.Add('Q');
list1.Add('W');
list1.Add('E');
list1.Add('R');
list1.Add('T');
list1.Add('Y');
list1.Add('U');
list1.Add('I');
list1.Add('O');
list1.Add('P');
list1.Add('q');
list1.Add('w');
list1.Add('e');
list1.Add('r');
list1.Add('t');
list1.Add('y');
list1.Add('u');
list1.Add('i');
list1.Add('o');
list1.Add('p'); list2.Add('A');
list2.Add('S');
list2.Add('D');
list2.Add('F');
list2.Add('G');
list2.Add('H');
list2.Add('J');
list2.Add('K');
list2.Add('L');
list2.Add('a');
list2.Add('s');
list2.Add('d');
list2.Add('f');
list2.Add('g');
list2.Add('h');
list2.Add('j');
list2.Add('k');
list2.Add('l'); list3.Add('Z');
list3.Add('X');
list3.Add('C');
list3.Add('V');
list3.Add('B');
list3.Add('N');
list3.Add('M');
list3.Add('z');
list3.Add('x');
list3.Add('c');
list3.Add('v');
list3.Add('b');
list3.Add('n');
list3.Add('m'); var List = new List<string>(); foreach (string str in words)
{
var type1 = ;
var type2 = ;
var type3 = ; var len = str.Length; foreach (char c in str)
{
if (list1.Any(x => x == c))
{
type1++;
}
else if (list2.Any(x => x == c))
{
type2++;
}
else if (list3.Any(x => x == c))
{
type3++;
}
else
{
break;
}
} if (type1 == len || type2 == len || type3 == len)
{
List.Add(str);
} }
return List.ToArray();
}
}

https://leetcode.com/problems/keyboard-row/#/description

leetcode500的更多相关文章

  1. [Swift]LeetCode500. 键盘行 | Keyboard Row

    Given a List of words, return the words that can be typed using letters of alphabet on only one row' ...

  2. Leetcode500.Keyboard Row键盘行

    给定一个单词列表,只返回可以使用在键盘同一行的字母打印出来的单词.键盘如下图所示. 示例: 输入: ["Hello", "Alaska", "Dad& ...

随机推荐

  1. 东北林业大学第12届ACM(打表)

    东北林业大学第12届ACMhttps://www.nowcoder.com/acm/contest/45#question F题和K题对大数运算的转化 首先F题,由于测试数据为接近10的100次方的大 ...

  2. Array.prototype.slice.call(arguments)探究

    Array.prototype.slice.call(arguments)能将具有length属性的对象转成数组 首先,slice有两个用法,一个是String.slice,一个是Array.slic ...

  3. log4net保存到数据库系列二:独立配置文件中配置log4net

    园子里面有很多关于log4net保存到数据库的帖子,但是要动手操作还是比较不易,从头开始学习log4net数据库日志一.WebConfig中配置log4net 一.WebConfig中配置log4ne ...

  4. centos7虚拟机安装出现license information

    问题:vm 10下安装CentOs7后无法启动.出现一个license information页面 解决办法:出现license information,即说明需要同意许可信息,输入1-回车-2-回车 ...

  5. PHP安全相关的配置(1)

    PHP作为一门强大的脚本语言被越来越多的web应用程序采用,不规范的php安全配置可能会带来敏感信息泄漏.SQL注射.远程包含等问题,规范的安全配置可保障最基本的安全环境.下面我们分析几个会引发安全问 ...

  6. linux yum安装httpd后,启动service httpd start 报错解决方案

    解决方案:

  7. springcould

     [Spring For All 社区周报] 「社区活动」(送书哦)Spring For All 第 1 期高手 QA 环节 — Spring Cloud 微服务实战http://spring4all ...

  8. RK3399 Android7.1 try 'jack-diagnose' or see Jack server log

    CPU:RK3399 系统:Android 7.1 Android 7.1系统使用 jack-server 作为 Java 代码编译器 jack-server 由两个配置文件来决定用户使用的端口 /h ...

  9. 解决“Replace wireless configuration ”默认被选上的问题

    方法一 1.打开 /home/tingpan/openwrt/barrier_breaker/feeds/luci/modules/admin-full/luasrc/model/cbi/admin_ ...

  10. 把存储过程SELECT INTO到临时表

    在开发过程中,很多时候要把结果集存放到临时表中,常用的方法有两种. 一. SELECT INTO1. 使用select into会自动生成临时表,不需要事先创建12 select * into #te ...