problem

748. Shortest Completing Word

题意:

solution1:

class Solution {
public:
string shortestCompletingWord(string licensePlate, vector<string>& words) {
string res = "";
unordered_map<char, int> freq;
int total = ;
for(char ch : licensePlate)
{
if(ch>='a' && ch<='z') { freq[ch]++; total++; }
else if(ch>='A' && ch<='Z') { freq[ch+]++; total++; }
} for(auto word:words)
{
int cnt = total;
unordered_map<char, int> t = freq;
for(auto ch:word)
{
if(t[ch] > ) { cnt--; t[ch]--; }//err...
}
if(cnt== && (res.empty() || res.size()>word.size())) res = word;
}
return res; }
};

solution2:

参考

1. Leetcode_easy_748. Shortest Completing Word;

2. Grandyang;

【Leetcode_easy】748. Shortest Completing Word的更多相关文章

  1. 【LeetCode】748. Shortest Completing Word 解题报告(Python)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 日期 题目地址:https://leetcode.c ...

  2. LeetCode 748 Shortest Completing Word 解题报告

    题目要求 Find the minimum length word from a given dictionary words, which has all the letters from the ...

  3. [LeetCode&Python] Problem 748. Shortest Completing Word

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

  4. leetcode 748. Shortest Completing Word

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

  5. 【Leetcode_easy】821. Shortest Distance to a Character

    problem 821. Shortest Distance to a Character solution1: class Solution { public: vector<int> ...

  6. 【Leetcode_easy】819. Most Common Word

    problem 819. Most Common Word solution: class Solution { public: string mostCommonWord(string paragr ...

  7. 【leetcode_easy】581. Shortest Unsorted Continuous Subarray

    problem 581. Shortest Unsorted Continuous Subarray 题意:感觉题意理解的不是非常明白. solution1: 使用一个辅助数组,新建一个跟原数组一模一 ...

  8. 748. Shortest Completing Word

    https://leetcode.com/problems/shortest-completing-word/description/ class Solution { public: string ...

  9. LeetCode算法题-Shortest Completing Word(Java实现)

    这是悦乐书的第309次更新,第330篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第178题(顺位题号是748).从给定的字典单词中查找最小长度单词,其中包含字符串lic ...

随机推荐

  1. Gitlab,Mac下生成SSH Key222

         git是分布式的代码管理工具,远程的代码管理是基于ssh的,所以要使用远程的git则需要ssh的配置.简单的说,Git - 版本控制工具:Github是一个网站,提供给用户空间创建git仓储 ...

  2. Mybatis配置文件中#{ }和${ }的区别

    #{ }和${ }都可以从map中取到相对应的值, 但是 #{ }采取的是预编译的方式(PreparedStatement)来执行sql语句,有效防止了sql注入问题 select * from bo ...

  3. 执行Commit时Oracle做哪些工作

    COMMIT是一个非常快的操作,当我们发布commit命令时,真正困难的动作已经完成,在数据库中已经执行了数据更改,所以已经完成了99%的任务,例如:下列操作已经产生: 1.在SGA(Buffer C ...

  4. DOM Diff(差分)算法

    1. 算法由来 React调用render()方法后,会生成一个React元素组成的树. 再次调用,生成一个新的树.React比较两者的差异,然后更新UI. 如果单纯使用算法,来查找两个DOM树的差异 ...

  5. 中检测到有潜在危险的 Request.Form 值。”

    添加富文本时  如果出现" 中检测到有潜在危险的 Request.Form 值.”   却不知道怎么排错时,就在HTML   或Web表格头部添加   ValidateRequest=&qu ...

  6. luogu 3919

    主席树 #include <iostream> #include <cstdio> #include <algorithm> #include <cmath& ...

  7. [bzoj 4872][六省联考2017]分手是祝愿

    传送门 Description N个灯按照1~N标号,按下一个开关i,所有标号是i的约数的开关都改变状态,目标是关掉所有的灯,如果当前最优策略≤k就直接按照最优策略走.否则随机按下一个开关.给出每个灯 ...

  8. 利用layer制作好看的弹出框

    一.下载layer http://layer.layui.com/ 二.效果图 三.代码 <!DOCTYPE html> <html lang="en"> ...

  9. 2018-2019-2 20165222《网络对抗技术》Exp9 Web安全基础

    1.实践过程记录 1.字符串型注入. 2.整数型注入 3.注入语句查看其他内容 4.xss是一种漏洞,这种漏洞允许用户输入脚本并且浏览器提交的时候不加编码.这种东西是最为流行并且有害的web应用的问题 ...

  10. /dev/mem同步写不能使用msync的MS_SYNC选项探究

    问题 做了个测试板子的程序,里面有一项写铁电的功能,要求写入之后立即断电,重启后校验数据准确性:铁电设计是通过内存地址直接映射的,于是,使用mmap直接映射了/dev/mem文件,自然地写入之后使用m ...