leetcode884
class Solution {
public:
void SplitString(const string& s, vector<string>& v, const string& c)
{
string::size_type pos1, pos2;
pos2 = s.find(c);
pos1 = ;
while (string::npos != pos2)
{
v.push_back(s.substr(pos1, pos2 - pos1)); pos1 = pos2 + c.size();
pos2 = s.find(c, pos1);
}
if (pos1 != s.length())
v.push_back(s.substr(pos1));
}
vector<string> uncommonFromSentences(string A, string B) {
vector<string> X;
map<string, int> M; vector<string> V1;
SplitString(A, V1, " ");
for (auto str : V1)
{
if (M.find(str) == M.end())//未找到此值
{
M.insert(make_pair(str, ));
}
else
{
M[str]++;
}
} vector<string> V2;
SplitString(B, V2, " ");
for (auto str : V2)
{
if (M.find(str) == M.end())//未找到此值
{
M.insert(make_pair(str, ));
}
else
{
M[str]++;
}
} for (auto m : M)
{
if (m.second == )
{
X.push_back(m.first);
}
}
return X;
}
};
leetcode884的更多相关文章
- [Swift]LeetCode884. 两句话中的不常见单词 | Uncommon Words from Two Sentences
We are given two sentences A and B. (A sentence is a string of space separated words. Each word co ...
- leetcode-884两句话中的不常见单词
''' 给定两个句子 A 和 B . (句子是一串由空格分隔的单词.每个单词仅由小写字母组成.) 如果一个单词在其中一个句子中只出现一次,在另一个句子中却没有出现,那么这个单词就是不常见的. 返回所有 ...
- Leetcode884.Uncommon Words from Two Sentences两句话中的不常见单词
给定两个句子 A 和 B . (句子是一串由空格分隔的单词.每个单词仅由小写字母组成.) 如果一个单词在其中一个句子中只出现一次,在另一个句子中却没有出现,那么这个单词就是不常见的. 返回所有不常用单 ...
随机推荐
- java jprofile
java -agentpath:/opt/jprofiler8/bin/linux-x64/libjprofilerti.so=port=8849,nowait -Xdebug -Xrunjdwp:t ...
- LeetCode OJ:Spiral Matrix(螺旋矩阵)
Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral or ...
- LeetCode OJ:Set Matrix Zeroes(设置矩阵0元素)
Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place. 这题要注意的 ...
- 移动端 HTML5 <video> 视频播放优化实践
遇到的挑战 移动端HTML5使用原生<video>标签播放视频,要做到两个基本原则,速度快和体验佳,先来分析一下这两个问题. 下载速度 以一个8s短视频为例,wifi环境下提供的高清视频达 ...
- react bootstrap-loader
1.install npm install bootstrap-loader jquery resolve-url-loader 2.webpack.config.js entry: ['bootst ...
- Azure Sql Database为某个数据库创建单独的访问账户
由于SQL Management Studio对Azure SQL Database支持不完美,不能使用图形界面,因此配置数据库就会有不同的麻烦,下面是本人配置访问账户的一些经验: 1.以管理员登陆之 ...
- HihoCoder 1097 kruscal
最小生成树二·Kruscal算法 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 随着小Hi拥有城市数目的增加,在之间所使用的Prim算法已经无法继续使用了——但是幸运的 ...
- JAVA软件配置—环境变量
环境Windows10,JDK,JRE1.8.0_102 鼠标右击左下角Windows图标,选择"系统"项: 点击"高级系统设置"——"环境变量&qu ...
- gulp 合格插件评判标准
官方插件列表: https://gulpjs.com/plugins/ 合格插件的判断标准 1. 不修改内容 如果一个插件一个文件都修改(无论是文案内容,文件路径),那么它就不是一个gulp ...
- MDK中STM32使用Printf函数详细解析【转载】
在用MDK调试STM32板子串口时,为了方便串口调试,调用了printf()函数,用Keil仿真是,串口不能正确的输出,软件仿真时,总是卡在那 里.有点纳闷,然后调用USART_SendData()函 ...