leetcode804
int uniqueMorseRepresentations(vector<string>& words) {
map<char, string> st;
st.insert(make_pair('a', ".-"));
st.insert(make_pair('b', "-..."));
st.insert(make_pair('c', "-.-."));
st.insert(make_pair('d', "-.."));
st.insert(make_pair('e', "."));
st.insert(make_pair('f', "..-."));
st.insert(make_pair('g', "--."));
st.insert(make_pair('h', "...."));
st.insert(make_pair('i', ".."));
st.insert(make_pair('j', ".---"));
st.insert(make_pair('k', "-.-"));
st.insert(make_pair('l', ".-.."));
st.insert(make_pair('m', "--"));
st.insert(make_pair('n', "-."));
st.insert(make_pair('o', "---"));
st.insert(make_pair('p', ".--."));
st.insert(make_pair('q', "--.-"));
st.insert(make_pair('r', ".-."));
st.insert(make_pair('s', "..."));
st.insert(make_pair('t', "-"));
st.insert(make_pair('u', "..-"));
st.insert(make_pair('v', "...-"));
st.insert(make_pair('w', ".--"));
st.insert(make_pair('x', "-..-"));
st.insert(make_pair('y', "-.--"));
st.insert(make_pair('z', "--.."));
map<string, int> stt;
int count = ;
for (auto s : words)
{
string str = "";
for (auto c : s)
{
str += st[c];
}
cout << str << endl;
if (stt.find(str) != stt.end())//存在
{
}
else
{
stt.insert(make_pair(str, ));
count++;
}
}
return count;
}
leetcode804的更多相关文章
- [Swift]LeetCode804. 唯一摩尔斯密码词 | Unique Morse Code Words
International Morse Code defines a standard encoding where each letter is mapped to a series of dots ...
- LeetCode804. Unique Morse Code Words
题目 国际摩尔斯密码定义一种标准编码方式,将每个字母对应于一个由一系列点和短线组成的字符串, 比如: "a" 对应 ".-", "b" 对应 ...
- Leetcode804.Unique Morse Code Words唯一摩尔斯密码词
国际摩尔斯密码定义一种标准编码方式,将每个字母对应于一个由一系列点和短线组成的字符串, 比如: "a" 对应 ".-", "b" 对应 &q ...
- LeetCode 804 唯一摩尔斯密码词
package com.lt.datastructure.Set; import java.util.TreeSet; /* * 一个摩斯码,对应一个字母.返回我们可以获得所有词不同单词翻译的数量. ...
随机推荐
- MongoCola使用教程 1 - MongoDB的基本操作和聚合功能---Mongdb客户端软件操作说明
前言 在开始正文之前,感谢博客园的Nosql爱好者对于MongoCola工具的试用(使用).特别感谢 呆呆 这位朋友的Bug报告,让我纠正了一个很严重的Bug.同时也感谢以前的多个网友在博客留言中给我 ...
- 手机app后台初学
初学者一看到接口就想到 不是interface.,但是这里不是,这里就是一个URL,app给这个URL传递参数,然后URL返回数据给APP,然后APP就能和服务端联动提供动态数据 举个最简单的例子,用 ...
- MySQL 福利彩票业务 如何存储毫秒微秒
朋友在做福利彩票业务,遇到一个存储毫秒微秒数据的需求,问我mysql里面有何解决方案.我脑中一搜索,以前没有关注到,于是去官网查看,找到11.3.6 Fractional Seconds in Tim ...
- pg_buffercache
查看缓冲区缓存的内容: create extension pg_buffercache; select c.relname, count(1) as buffers from pg_class c j ...
- 一个通用Makefile详解
我们在Linux环境下开发程序,少不了要自己编写Makefile,一个稍微大一些的工程下面都会包含很多.c的源文 件. 如果我们用gcc去一个一个编译每一个源文件的话,效率会低很多,但是如果我们可以写 ...
- 如何突破JAVA程序员三年的门槛
第一阶段:三年 我认为三年对于程序员来说是第一个门槛,这个阶段将会淘汰掉一批不适合写代码的人.这一阶段,我们走出校园,迈入社会,成为一名程序员,正式从书本 上的内容迈向真正的企业级开发.我们知道如何团 ...
- 特例模式(Special Case Pattern)与空对象模式(Null Pointer Pattern)—— 返回特例对象而非 null
返回 null 值,基本上是在给自己增加工作量,也是给调用者添乱.只有一处没有检查返回的是否为 null,程序就会抛 NullPointerException 异常. 如果你打算在方法中返回 null ...
- matlab 与 modelsim 联调 cic抽取滤波器
注:本设计的参数为:D=2,R=5,N=3:时钟频率为50mhz,输入信号为有符号8位,根据公式bmax=bin+N*log(2,R*D):可以得到bmax=18: 1,cic抽取滤波器原理 网上资料 ...
- LA3263 That Nice Euler Circuits
题意 PDF 分析 欧拉定理:设平面内顶点数.边数.面数分别为\(V,E,F\),则\(V+F-E=2\). 枚举每对线段求交点,注意去重. 另外注意第n个端点和第一个端点重合. 时间复杂度\(o(T ...
- SpringMVC的启动过程
前言 下面是一个SpringMVC应用的配置文件,需要注意两个地方,一个是ContextLoaderListener,一个是dispatcherServlet.web容器正是通过这两个配置才和spri ...