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( ...
 
随机推荐
- java之静态方法,静态变量
			
在自动化测试中,经常会用到静态方法和静态变量.那么什么是静态方法和静态变量呢?以及在什么情况下使用呢?下面来说一说 静态方法和静态变量是使用公共内存空间的,就是说所有对象都可以直接引用,不需要创建对象 ...
 - Python 学习笔记(十一)Python语句(二)
			
For 循环语句 基础知识 for循环可以遍历任何序列的项目,如一个列表或者一个字符串. 语法: for 循环规则: do sth >>> for i in "python ...
 - Qt5连接Mysql环境配置
			
已安装的环境:Mysql5.7 64bit ,Qt5.12 64bit. 到mysql官方下载mysql5.7 64bit的压缩包,解压,复制下图框内四个文件. 将四个文件复制到Qt安装目录下bin目 ...
 - 竞赛题解 - Karp-de-Chant Number(BZOJ-4922)
			
Karp-de-Chant Number(BZOJ-4922) - 竞赛题解 进行了一次DP的练习,选几道题写一下博客~ 标签:BZOJ / 01背包 / 贪心 『题目』 >> There ...
 - Redis Cluster Notes
			
Redis Cluster Goal: 1. 最大支持1000个节点的高性能.可线性扩展集群:集群架构中无Proxy层,主从间采用异步同步机制(replication),无merge层(不支持 ...
 - Java : logback简单配置
			
需要把logback.xml文件放在类路径下,如果是spring boot项目可以用 logging.config=classpath:log/xxxxxx.xml来指定配置文件 logback la ...
 - mysql 库和表占用空间查询
			
1. 查看该数据库实例下所有库大小,得到的结果是以MB为单位 as sum from information_schema.tables; 2.查看该实例下各个库大小 as total_mb, as ...
 - Python学习:4.运算符以及数据类型解析
			
运算符 一.算数运算: 二.比较运算: 三.赋值运算 四.逻辑运算 五.成员运算 基本数据类型 一.Number(数字) Python3中支持int.float.bool.complex. 使用内置的 ...
 - JDBC与Java数据库编程基础
			
一.JDBC 概述 1.什么是JDBC 称为Java数据库连接,它是一种用于数据库访问的应用程序API,由一组用Java语言编写的类和接口组成,有了JDBC就可以用同一的语法对多种关系数据库进行访问, ...
 - [Real World Haskell翻译]第27章 网络通信和系统日志 Sockets and Syslog
			
第27章 网络通信和系统日志 Sockets and Syslog 基础网络 在本书的前面几章,我们讨论了运转在网络上的服务.其中的两个例子是客户端/服务器架构的数据库和Web服务.当需要制定一个新的 ...