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( ...
随机推荐
- POJ 1651 Multiplication Puzzle(类似矩阵连乘 区间dp)
传送门:http://poj.org/problem?id=1651 Multiplication Puzzle Time Limit: 1000MS Memory Limit: 65536K T ...
- HDU 2088 Box of Bricks(脑洞)
传送门: http://acm.hdu.edu.cn/showproblem.php?pid=2088 Box of Bricks Time Limit: 1000/1000 MS (Java/Oth ...
- Tag It 一款 Jquery控件,当你在文本框中输入逗号时,自动帮你分隔开相关内容
Demo地址:http://webspirited.com/tagit/ 使用方法: 除了JQuery脚本外,下面的脚本也是必须的,这些脚本你都可以去GitHub下载:https://github.c ...
- Gradle Goodness: Changing Name of Default Build File
Gradle uses the name build.gradle as the default name for a build file. If we write our build code i ...
- unittest单元测试框架之测试用例的跳过(skip) (六)
1.跳过测试用例的方法 @unittest.skip("don't run this case!"): @unittest.skipIf(3<2,"don't ru ...
- Oracle中按规定的字符截取字符串
CREATE OR REPLACE FUNCTION "F_SPLIT" (p_str IN CLOB, p_delimiter IN VARCHAR2) RETURN ty_st ...
- [异常笔记] zookeeper集群启动异常: Cannot open channel to 2 at election address ……
- ::, [myid:] - WARN [WorkerSender[myid=]:QuorumCnxManager@] - Cannot open channel to at election ad ...
- ATM购物作业
一. 基本需求 模拟实现一个ATM + 购物商城程序 额度 15000或自定义 实现购物商城,买东西加入 购物车,调用信用卡接口结账 可以提现,手续费5% 支持多账户登录 支持账户间转账 记录日常消费 ...
- HTML5新标签兼容——> <!--<if lt IE 9><!endif-->
第一种方法:(使用html5shiv) <!--[if lt IE9]> <script src="http://html5shiv.googlecode.com/svn/ ...
- 正则验证input输入,要求只能输入正数,小数点后保留两位。
<input type="number" step="1" min="0" onkeyup="this.value= thi ...