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( ...
随机推荐
- Python入门基础:代码的编码风格
每种语言都有自己的编码风格,对于Python这种比较注重于空格的影响的代码而言,其风格也是相当重要的. 主要包括以下几点: 1:使用 4 空格缩进,而非 TAB .在小缩进(可以嵌套更深)和大缩进( ...
- 在spring添加注解时,第一行package报错configure build path
练习spring的ioc的注解的时候写上注解就会在第一行package报错configure build path. 用的spring4.2.4的jar包.经过上网查阅资料,可能是jar包冲突,解决办 ...
- 为什么我们需要DTO?
最近在写代码时突然产生了这个疑惑,我们为什么需要DTO进行数据传输呢? 要了解DTO首先我们要知道什么是DAO,DAO就是数据库的一个数据模型,是一个类文件里面存储着数据库的字段及其getter&am ...
- Python基础 List和Tuple类型
python 创建list python 内置一种数据类型是列表: 列表是一种有序的集合,可以随时添加和 删除其中的元素,list 中的元素是按照顺序排列的.构建list 直接用 [ ], list ...
- 网站程序application, session, cookie区别的一点小总结
cookie:是存放于本地的文件,可以设置期限,一般来讲是比较小文本或键值对等,主要用于记录用户浏览信息,账号密码等等.可以让人们的登录变得方便,因为有了cookie,在一段时间内就可以自动登录以前所 ...
- 『C++』Temp_2018_12_13 函数指针
#include <iostream> #include <string> using namespace std; class Test{ private: string n ...
- mybatis使用*号查询数据丢失问题
使用*号的SQL语句:select * from 表名 在开发过程中可能你会发现使用mybatis框架爱作为持久层时,写的SQL语句在工具里面查询数据是可以查到想要的数据的,但是在项目中会出现数据丢失 ...
- Oracle->oracle单实例Shell脚本[20180122]
脚本主要用于redhat平台安装11g和12c软件 依赖包检查与安装 用户.组检查与安装 系统内核.用户限制 防火墙.selinux关闭 注意,linux组脚本 ...
- keepalived+haproxy 安装配置
1.安装配置keepalived 修改配置文件/etc/keepalived/keepalived.conf ! Configuration File for keepalived global_de ...
- 正则表达式-Regular expression学习笔记
正则表达式 正则表达式(Regular expression)是一种符号表示法,被用来识别文本模式. 最近在学习正则表达式,今天整理一下其中的一些知识点 grep - 打印匹配行 grep 是个很强大 ...