public class Solution
{
public string ShortestCompletingWord(string licensePlate, string[] words)
{
var list = words.OrderBy(x => x.Length);
var pattern = licensePlate.ToLower();
var dic = new Dictionary<char, int>();
foreach (var p in pattern)
{
if (p >= && p <= )
{
if (!dic.ContainsKey(p))
{
dic.Add(p, );
}
else
{
dic[p]++;
}
}
} foreach (var word in list)
{
bool find = true;
var dic2 = new Dictionary<char, int>();
foreach (var p in word)
{
if (!dic2.ContainsKey(p))
{
dic2.Add(p, );
}
else
{
dic2[p]++;
}
} foreach (var d in dic)
{
if (!dic2.ContainsKey(d.Key) || dic2[d.Key] < dic[d.Key])
{
find = false;
break;
}
}
if (find)
{
return word;
}
} return "";
}
}

leetcode748的更多相关文章

  1. [Swift]LeetCode748. 最短完整词 | Shortest Completing Word

    Find the minimum length word from a given dictionary words, which has all the letters from the strin ...

随机推荐

  1. WCF 采用net.tcp协议实践(转)

    概述 与Socket相比,WCF真是爽得不得了,其基本指导思想为SOA——面向服务. 其基本配置在于ABC(Address,Binding,Contract),通常,只要这三个因素配置对了,那么,基本 ...

  2. MySQL Inception--原理和注意事项

    ========================================================= MySQL Inception原理图 ======================= ...

  3. PHP安装sqlsrv和memcache扩展步骤

    做了两天的实验才终于摸清楚如何将PHP连接上sqlserver数据库,以及怎样通过修改virtualhost文件来重定向,因为走得弯路比较多所以很想分享一下这次的心路历程. 第一步:安装wamp等类似 ...

  4. MySQL Group Replication

    group replication是一种全新的高可用,高扩张的MySQL集群服务.高一致性,基于原生复制及paxos协议的组复制技术,以插件方式提供一致数据安全保证:高容错性,大多数服务正常就可继续工 ...

  5. 产品思维&技术思维&工程思维

    产品思维 产品思维的起源是用户(或客户)价值.用户价值是通过技术手段以产品或服务的形态去解决用户的痛点,或带去爽点.毫无疑问,工程师在日常工作中应时刻关注并理清自己的工作与用户(或客户)价值的联系,并 ...

  6. ORA-10997:another startup/shutdown operation of this instance in progress解决方法

    SQL> startup ORA-10997: another startup/shutdown operation of this instance inprogress ORA-09967: ...

  7. Nginx隐藏主机信息,proxy_hide_header 与fastcgi_hide_header

    Nginx中proxy_hide_header 与fastcgi_hide_header都可以隐藏主机头信息,两者在具体使用时还是有着一定的区别的.刚好业务使用的nginx反向代理在显示响应头时将后端 ...

  8. jQuery如何取得HiddenField值(转)

    <f:HiddenField runat="server" ID="cat_id" Text="ssss"/> var strD ...

  9. 栈的一个实例——Dijkstra的双栈算术表达式求值法

    Dijkstra的双栈算术表达式求值法,即是计算算术表达式的值,如表达式(1 + ( (2+3) * (4*5) ) ). 该方法是 使用两个栈分别存储算术表达式的运算符与操作数 忽略左括号 遇到右括 ...

  10. R语言学习——数据分析

    complete.cases查看缺失值 箱图: