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; /* * 一个摩斯码,对应一个字母.返回我们可以获得所有词不同单词翻译的数量. ...
随机推荐
- QT Designer 的汉化
Designer是很好用的设计器,通过 pip 安装PyQt5之后,一般都是英文的 所以给有需要的人带来汉化的包(这个是通过替换 translations 文件夹来实现的) translations ...
- ARM汇编指令集5
为什么需要多寄存器访问指令? ldr/str每周期只能访问4字节内存,如果需要批量读取.写入内存时太慢,解决方案是stm/ld 举例(uboot start.S 537行) stmia sp, ...
- mcake活动维护,检查 ★ ★
一.检查火狐浏览器.chrome浏览器.ie8.9.10.11是否显示正常 二.对比设计稿 三.动画添加 四.检查图片是否失真 五.ie8空按钮无法点击 六.官网banner制作
- .net 学习路线感想(转)
从上到大学到现在工作,已经有六年多了,发现学习编程到以开发为工作也是一个挺长的过程的. 大学中,从c语言到java.C#到其他各种语言的学习,还有其他知识的学习如:数据库(oracle.sql Ser ...
- java网络编程客户端与服务端原理以及用URL解析HTTP协议
常见客户端与服务端 客户端: 浏览器:IE 服务端: 服务器:web服务器(Tomcat),存储服务器,数据库服务器. (注:会用到Tomact服务器,在webapps下有一个自己创建的目录myweb ...
- 剑指offer-第五章优化时间和空间效率(在字符串中第一次出现切只出现一次的字符)
题目:在字符串中第一次出现切只出现一次的字符 思路:用HashMap来存放对应的char值和该char出现的次数.做一次变量就可以得到第一个只出现一次的字符. Java代码: import java. ...
- CSS冷门但有用的知识整合
1. 滚动条样式设置 The ::-webkit-scrollbar CSS pseudo-element(伪元素) affects the style of the scrollbar of an ...
- Java知识点汇总
Java中泛型的本质 Java中静态变量的适用场景 Java类加载原理及类加载器 Java中对Clone的理解 Java中HashMap的实现 Java中Collection和Collections的 ...
- redis事务和redis集群
一.事务(相对mysql来说简单) 1. 比较 ①:mysql ----->start trantation ---->普通sql ------->回滚rollback------& ...
- 【转】Jmeter参数化
参数化:简单的来理解一下,我们录制了一个脚本,这个脚本中有登录操作,需要输入用户名和密码,假如系统不允许相同的用户名和密码同时登录,或者想更好的模拟多个用户来登录系统. 这个时候就需要对用户名和密码进 ...