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. test20190324 树

    题意 树(tree.cpp/c/pas) [题目背景] 这道题标算在评测机上的时间约为自己电脑的2/3 [问题描述] [输入格式] 共 n+2 行.第 1 行 1 个数,n. 后面 2-n 行,每行两 ...

  2. 动画Completed事件里获取执行该动画的UI对象

    转:http://www.cnblogs.com/xyq/p/3775732.html 昨天群里有位童鞋提出如何在动画完成事件Completed里获取到执行该动画的UI对象. WPF里动画的Compl ...

  3. adnanh webhook 框架request values 说明

      request values 在adnanh webhook 是比较重要的,规则触发以及命令参数传递都是通过它 支持的request values 类似 http header 查询参数 play ...

  4. SpringMVC Controller 介绍及常用注解

    摘要: @Controller.@RequestMapping(属性:value.params .method.headers).@PathVariable.@RequestParam.@Cookie ...

  5. java 的关键字 native

    native native 关键字说明其修饰的方法是一个原生态方法,方法对应的实现不是在当前文件,而是在用其他语言(如C和C++)实现的文件中.Java语言本身不能对操作系统底层进行访问和操作,但是可 ...

  6. LINQ TO SQL 中的join(转帖)

    http://www.cnblogs.com/ASPNET2008/archive/2008/12/21/1358152.html join对于喜欢写SQL的朋友来说还是比较实用,也比较容易接受的东西 ...

  7. php中is_null,empty,isset,unset 的区别详细介绍

    is_null, empty, isset, unset 我们先来看看这4个函数的描述. isset 判断变量是否已存在(配置)unset 把变量删除(释放)掉empty 判断变量是否为空is_nul ...

  8. QWidget背景(透明)问题

    一. 背景設定為成黑色,前景色設為白色. 方法一.paltette方式,經測試,該方法不會影響到其他控制元件,建議使用 QPalette bgpal = palette();bgpal.setColo ...

  9. debian之apt源

    美国的 deb http://ftp.us.debian.org/debian stable main contrib non-freedeb-src http://ftp.us.debian.org ...

  10. bzoj 2571: Getting Rid of the Holidays

    Description B国的国王Johnny在他在位的短短几年里制定了不少的节日(事实上没超过30个),这些节日是为了尊敬各种各样他所想到的东西而设立的.每过一段固定的时间,一个节日将会被举行(即节 ...