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. XSLT可扩展样式表语言转换 System.Xml.Xsl、XslCompiledTransform类

    XML文件 books.xml: <?xml version="1.0" encoding="utf-8" ?> <bookstore> ...

  2. virtual box启动error

      启动 VirtualBox 的时候提示 “获取 VirtualBox COM 对象失败” 错误详情 “获取 VirtualBox COM 对象失败” 的错误详情: 获取 VirtualBox CO ...

  3. 哇!吐槽!oh shit

    一个jsp写了5000行,我尼玛醉了,看晕了-2017年10月12日10:19:40

  4. css 学习笔记 菜鸟

    1 CSS 规则由两个主要的部分构成:选择器,以及一条或多条声明: 选择器通常是您需要改变样式的 HTML 元素. 每条声明由一个属性和一个值组成.每个属性有一个值.属性和值被冒号分开.CSS声明总是 ...

  5. hive优化,并行查询

    1.hive中控制并行执行的参数有如下几个: $ bin/hive -e set | grep parall hive.exec.parallel=false hive.exec.parallel.t ...

  6. 学到了林海峰,武沛齐讲的Day24-完 对象和实例

    学到这里估计就是坎了...日志都不想写了.. 对象和实例

  7. JSON.parseObject的几种用法

    https://blog.csdn.net/a18827547638/article/details/80272099 https://blog.csdn.net/a18827547638/artic ...

  8. Qt在pro中实现条件编译

    https://www.cnblogs.com/Braveliu/p/5107550.html https://blog.csdn.net/simonforfuture/article/details ...

  9. 浅谈"$fake$树"——虚树

    树形$dp$利器——"$fake$"树(虚树$qwq$)  前置知识: $1.$$dfs$序 $2.$倍增法或者树链剖分求$lca$  问题引入: 在许多的树形动规中,很多时候点特 ...

  10. 解决chrome浏览器自动填充密码

    chrome会自动填充密码,解决方法很简单 使用下面的参考代码即可: <input type="password" readonly οnfοcus="this.r ...