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; /* * 一个摩斯码,对应一个字母.返回我们可以获得所有词不同单词翻译的数量. ...
随机推荐
- language model ——tensorflow 之RNN
代码结构 tf的代码看多了之后就知道其实官方代码的这个结构并不好: graph的构建和训练部分放在了一个文件中,至少也应该分开成model.py和train.py两个文件,model.py中只有一个P ...
- 实验二. 使用LoadRunner进行压力测试
实验二. 使用LoadRunner进行压力测试 一. LoadRunner 概要介绍 1.1简介 LoadRunner 是一种预测系统行为和性能的工业标准级负载测试工具.通过以模拟上千万用户实 ...
- ZOJ 3203 Light Bulb(数学对勾函数)
Light Bulb Time Limit: 1 Second Memory Limit: 32768 KB Compared to wildleopard's wealthiness, h ...
- LeetCode OJ:Best Time to Buy and Sell Stock II(股票买入卖出最佳实际II)
Say you have an array for which the ith element is the price of a given stock on day i. Design an al ...
- 条款2:尽量以const enum inline 来替换 #define
这里说的意思其实相当于,宁可以用编译器来替换预处理器 因为使用预处理器可能使得被处理过的东西无法进入符号表,例如 #define MAXLEN 16 这里的MAXLEN并没有进入符号表,这样有编译错误 ...
- html的meta总结,html标签中meta属性使用介绍(转)
html的meta总结,html标签中meta属性使用介绍 2014年11月5日 5928次浏览 引子 之前的我的博客中对于meta有个介绍,例如:http://www.haorooms.com/po ...
- [Hive]HiveServer2概述
1. HiveServer1 HiveServer是一种可选服务,允许远程客户端可以使用各种编程语言向Hive提交请求并检索结果.HiveServer是建立在Apache ThriftTM(http: ...
- 剑指Offer(第二版)面试案例:树中两个节点的最低公共祖先节点
(尊重劳动成果,转载请注明出处:http://blog.csdn.net/qq_25827845/article/details/74612786冷血之心的博客) 剑指Offer(第二版)面试案例:树 ...
- 2017年终巨献阿里、腾讯最新Java程序员面试题,准备好进BAT了吗
Java基础 进程和线程的区别: Java的并发.多线程.线程模型: 什么是线程池,如何使用? 数据一致性如何保证:Synchronized关键字,类锁,方法锁,重入锁: Java中实现多态的机制是什 ...
- PS基础教程[6]如何快速制作一寸照片
一寸照片使我们经常会用到的,很多的证件照都是使用一寸的照片作为存档的.写这个经验也是因为刚刚有网友求助做一寸照片,所以就顺便写个经验.废话不多说了,进入正题,PS基础教程之快速制作一寸的照片. 制作方 ...