Missing String

 描述:

Given two strings, you have to find the missing string.

Have you met this question in a real interview?

Yes
Example

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的更多相关文章

  1. LintCode Interleaving String

    Given three strings: s1, s2, s3, determine whether s3 is formed by the interleaving of s1 and s2. Ex ...

  2. [LintCode] Scramble String 爬行字符串

    Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrin ...

  3. Lintcode: Rotate String

    Given a string and an offset, rotate string by offset. (rotate from left to right) Example Given &qu ...

  4. ActiveX(三)ActiveX 调用 Js

    在上一篇随笔: ActiveX(二)Js 监听 ActiveX中的事件  中,已经可以实现 Js 监听 ActiveX中的事件,至此.Js 和 ActiveX 已经可以实现双向通讯了.但是.这样的实现 ...

  5. C#操作 word代码

    #region 读取word /// <summary> /// 读取word所有文字内容(不包含表格) /// </summary> /// <returns>w ...

  6. ASP.NET mvc异常处理的方法

    第一种:全局异常处理 1.首先常见保存异常的类(就是将异常信息写入到文件中去) public class LogManager { private string logFilePath = strin ...

  7. c#操作word表格

    http://www.webshu.net/jiaocheng/programme/ASPNET/200804/6499.html <% if request("infoid" ...

  8. DataGrid3

    a标签,DataGrid的数据绑定 1.function aa(id, url) {            //alert(id);            window.open(url + '&am ...

  9. DataGrid2

    1.DataGrid的button属性设置 CommandName="ToEdit": 对其中的button按钮进行选择: CommandArgument='<%#Eval( ...

随机推荐

  1. 【题解】洛谷P1311 [NOIP2011TG] 选择客栈(递推)

    题目来源:洛谷P1311 思路 纯暴力明显过不了这道题 所以我们要考虑如何优化到至多只能到nlogn 但是我们发现可以更优到O(n) 我们假设我们当前寻找的是第二个人住的客栈i 那么第一个人住的客栈肯 ...

  2. WinCE下的串口通信开发(VS2005,VB.Net,VC++)

    WinCE下的串口通信开发(VS2005,VB.Net,VC++)   WinCE下的串口通信开发 一.利用Visual Basic 开发很简单,因为有现成的控件可以直接调用 以VS2005为例,首先 ...

  3. oracle 数据库密码生产同步模拟环境 ,随记常用命令

    1.查看当前open用户 select username,account_status,expiry_date,profile from dba_users; 2.查看目前的密码过期策略 select ...

  4. Java关于NIO类的详解

    一.IO与NIO的区别: 前提我们先说一说java IO: Java中使用IO(输入输出)来读取和写入,读写设备上的数据.硬盘文件.内存.键盘......,根据数据的走向可分为输入流和输出流,这个走向 ...

  5. 竞赛题解 - [CF 1080D]Olya and magical square

    Olya and magical square - 竞赛题解 借鉴了一下神犇tly的博客QwQ(还是打一下广告) 终于弄懂了 Codeforces 传送门 『题目』(直接上翻译了) 给一个边长为 \( ...

  6. Redis(五):Redis的持久化

    Redis的持久化目录导航: 总体介绍 RDB(Redis DataBase) AOF(Append Only File) 总结(Which one) 总体介绍 官网介绍 RDB(Redis Data ...

  7. Robots协议(摘)

    robots协议 Robots协议(也称为爬虫协议.机器人协议等)的全称是“网络爬虫排除标准”(Robots Exclusion Protocol),网站通过Robots协议告诉搜索引擎哪些页面可以抓 ...

  8. Linux的数据传输

    1. sz 与 rz sz:将选定的文件从本地发送(send)到远端机器 rz:运行该命令会弹出一个文件选择窗口,从本地选择文件夹,接收(receive)从远端的文件 mac 下使用 brew 安装: ...

  9. Python知乎热门话题爬取

    本例子是参考崔老师的Python3网络爬虫开发实战写的 看网页界面: 热门话题都在 explore-feed feed-item的div里面 源码如下: import requests from py ...

  10. 爬虫-windows下安装Scrapy及scrapy模块介绍

    一:安装wheel  wheel介绍 二:安装twisted twisted是由python编写的一款基于事件驱动的网络引擎,使用twisted模块将python的异步请求(异步模型介绍)成为可能且简 ...