lintcode: Missing String
Missing String
Given two strings, you have to find the missing string.
Given a string str1 = This is an example
Given another string str2 = is example
Return ["This", "an"]
代码
class Solution {
public:
/*
* @param : a given string
* @param : another given string
* @return: An array of missing string
*/
vector<string> missingString(string str1, string str2) {
// Write your code here
vector<string> vec1;
vector<string> vec2;
vector<string> res; string buf;
stringstream ss1(str1); //字符流
while (ss1 >> buf) {
vec1.push_back(buf);
} stringstream ss2(str2);
while (ss2 >> buf) {
vec2.push_back(buf);
} for (int i = ; i < vec1.size(); i++) {
vector<string>::iterator it;
it = find(vec2.begin(), vec2.end(), vec1[i]);
if (it == vec2.end()) {
res.push_back(vec1[i]);
}
}
return res;
}
};
lintcode: Missing String的更多相关文章
- LintCode Interleaving String
Given three strings: s1, s2, s3, determine whether s3 is formed by the interleaving of s1 and s2. Ex ...
- [LintCode] Scramble String 爬行字符串
Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrin ...
- Lintcode: Rotate String
Given a string and an offset, rotate string by offset. (rotate from left to right) Example Given &qu ...
- ActiveX(三)ActiveX 调用 Js
在上一篇随笔: ActiveX(二)Js 监听 ActiveX中的事件 中,已经可以实现 Js 监听 ActiveX中的事件,至此.Js 和 ActiveX 已经可以实现双向通讯了.但是.这样的实现 ...
- C#操作 word代码
#region 读取word /// <summary> /// 读取word所有文字内容(不包含表格) /// </summary> /// <returns>w ...
- ASP.NET mvc异常处理的方法
第一种:全局异常处理 1.首先常见保存异常的类(就是将异常信息写入到文件中去) public class LogManager { private string logFilePath = strin ...
- c#操作word表格
http://www.webshu.net/jiaocheng/programme/ASPNET/200804/6499.html <% if request("infoid" ...
- DataGrid3
a标签,DataGrid的数据绑定 1.function aa(id, url) { //alert(id); window.open(url + '&am ...
- DataGrid2
1.DataGrid的button属性设置 CommandName="ToEdit": 对其中的button按钮进行选择: CommandArgument='<%#Eval( ...
随机推荐
- 【题解】洛谷P1283 平板涂色(搜索+暴力)
思路 看到n<16 整个坐标<100 肯定想到暴力啊 蒟蒻来一发最简单易懂的题解(因为不会DP哈 首先我们用map数组来存坐标图 注意前面的坐标需要加1 因为输入的是坐标 而我们需要的是格 ...
- win7系统安装VS2013后,连不上远程sqlserver数据库解决办法
刚搬了地方,顺便把电脑重做了系统,把sql2012和vs2013装好,怎么弄也连不上远程的数据库了,用程序连IIS直接死掉,用ssms连也是直接失去响应,开始以为是网线端口被运营商封杀了,最后发现不是 ...
- Struts2-01
一.Struts2的介绍 讲Struts2框架之前,我们需要知道框架是什么呢?估计大多数初学者都只知道其名却不知其意,框架就是一个半成品,别人将一些功能已经写好了,我们只需要拿来用即可,像我们之前使用 ...
- Context initialization failed org.springframework.beans.factory.BeanCreationException
严重: Context initialization failed org.springframework.beans.factory.BeanCreationException: Error cre ...
- oracle 数据库密码生产同步模拟环境 ,随记常用命令
1.查看当前open用户 select username,account_status,expiry_date,profile from dba_users; 2.查看目前的密码过期策略 select ...
- ASP.Net 中的三种控件
---恢复内容开始--- 第一种:HTML控件 ASP.Net把HTML控件当成普通字符串渲染到浏览器端,不去检查正确性.无法在服务器端进行处理. 比如: <input111 type=&quo ...
- iOS视频播放(AVFoundation)
iOS视频播放(AVFoundation) 关于iOS平台的音视频处理,苹果官方提供了OC和swift接口的AVFoundation框架,可以进行各种音频播放和剪辑,底层实现使用了GPU加速,编解码效 ...
- Vue--- vue-cli 脚手架 安装 -reeber
vue-cli 脚手架 安装 一. node安装 1)如果不确定自己是否安装了node,可以在命令行工具内执行: node -v (检查一下 版本): 2)如果 执行结果显示: xx 不是内部命 ...
- 一个 Safari 的 new Date() bug
开发「bufpay.com 个人即时到账收款平台」后台套餐修改功能的时候碰到一个 new Date() bug. 既在 Safari 里面不支持 var t = new Date('2018-06-1 ...
- [videos系列]日本的videos视频让男人产生了哪些误解?
转载自:[videos系列]日本的videos视频让男人产生了哪些误解? 日本的videos视频是每个男人成长过程中都会看的启蒙教育片,也是男人在成年后调剂生活的必需品,但是由于影视作品是艺术的,是属 ...