字符串子序列查找问题,设置两个指针,一个指向子序列,另一个指向待查找的序列,查找个字符串一次即可判断。
 
 #include <iostream>
#include <string.h>
using namespace std;
char s[];
char t[];
int main() { while(cin>>s>>t){
int length1=strlen(s);
int length2=strlen(t);
int i=,j=;
for(i=,j=;i<length1&&j<length2;){
if(s[i]==t[j]){
i++;
j++;
}else{
j++;
}
}
if(i==length1)
cout<<"Yes"<<endl;
else
cout<<"No"<<endl;
}
return ;
}

附:

Time Limit: 1000MS   Memory Limit: 30000K
Total Submissions: 29592   Accepted: 12269

Description

You have devised a new encryption technique which encodes a message by inserting between its characters randomly generated strings in a clever way. Because of pending patent issues we will not discuss in detail how the strings are generated and inserted into the original message. To validate your method, however, it is necessary to write a program that checks if the message is really encoded in the final string.

Given two strings s and t, you have to decide whether s is a subsequence of t, i.e. if you can remove characters from t such that the concatenation of the remaining characters is s.

Input

The input contains several testcases. Each is specified by two strings s, t of alphanumeric ASCII characters separated by whitespace.The length of s and t will no more than 100000.

Output

For each test case output "Yes", if s is a subsequence of t,otherwise output "No".

Sample Input

sequence subsequence
person compression
VERDI vivaVittorioEmanueleReDiItalia
caseDoesMatter CaseDoesMatter

Sample Output

Yes
No
Yes
No

All in All - poj 1936 (子串)的更多相关文章

  1. POJ 1936 All in All(模拟)

    All in All 题目链接:http://poj.org/problem?id=1936 题目大意:判断从字符串s2中能否找到子串s1.字符串长度为10W. Sample Input sequen ...

  2. POJ 1936 All in All 匹配, 水题 难度:0

    题目 http://poj.org/problem?id=1936 题意 多组数据,每组数据有两个字符串A,B,求A是否是B的子串.(注意是子串,也就是不必在B中连续) 思路 设置计数器cnt为当前已 ...

  3. OpenJudge/Poj 1936 All in All

    1.链接地址: http://poj.org/problem?id=1936 http://bailian.openjudge.cn/practice/1936 2.题目: All in All Ti ...

  4. poj 1936 All in All(水题)

    题目链接:http://poj.org/problem?id=1936 思路分析:字符串子序列查找问题,设置两个指针,一个指向子序列,另一个指向待查找的序列,查找个字符串一次即可判断.算法时间复杂度O ...

  5. poj 1936 All in All

    All in All Time Limit: 1000 MS Memory Limit: 30000 KB 64-bit integer IO format: %I64d , %I64u   Java ...

  6. Poj 1936,3302 Subsequence(LCS)

    一.Description(3302) Given a string s of length n, a subsequence of it, is defined as another string ...

  7. POJ 1936

    #include<iostream> #include<string> using namespace std; int main() { //freopen("ac ...

  8. 简单的字符串比较题 POJ 1936

    Description You have devised a new encryption technique which encodes a message by inserting between ...

  9. POJ 1936 All in All(串)

    All in All Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 27537 Accepted: 11274 Descript ...

随机推荐

  1. 阿里云乌班图16配置-PHP环境(包括mysql及apache安装)

    1. 安装apache  apt-get update apt-get install apache2 service apache2 restart   通过浏览器访问服务器的IP,如果出现Apac ...

  2. [转] matlab获取时间日期

    原文:EmanLee, Eman Lee's Space (blog, website) 在MATLAB中得到系统当前日期.时间也是经常用到的内容,由以下函数实现. 1.生成指定格式日期和时间 dat ...

  3. Easyui datagrid 隐藏多选框 checkbox

    在加载 表格的时候添加事件:onLoadSuccess 在事件中写入下面句,用空代替原有HTML 达到取消效果. $(".datagrid-header-check").html( ...

  4. Gitlab系列九之取消用户注册页面和删除用户

    一.取消用户注册页面 Admin Area--->Settings--->Sign-up enabled(取消前面的勾)---save 二.删除用户 Users----Destroy(点他 ...

  5. 【招聘App】—— React/Nodejs/MongoDB全栈项目:个人中心&退出登录

    前言:最近在学习Redux+react+Router+Nodejs全栈开发高级课程,这里对实践过程作个记录,方便自己和大家翻阅.最终成果github地址:https://github.com/66We ...

  6. 安装dubbo-admin报错 URIType BeanCreationException

    安装dubbo-admin报错 URIType BeanCreationException 学习了:https://blog.csdn.net/lsm135/article/details/52725 ...

  7. spock+maven+junitReport接口测试框架

    1.POM 文件: <?xml version="1.0" encoding="UTF-8"?><project xmlns="ht ...

  8. 文档对象模型-DOM(一)

    首先看一下DOM树结构: 每个节点都是一个对象,拥有方法和属性. 脚本可以访问以及更新DOM树(不是源代码). 针对DOM树的修改都会反映到浏览器. 访问并更新DOM树需要两个步骤:   一.定位到与 ...

  9. 【Python3 爬虫】06_robots.txt查看网站爬取限制情况

    大多数网站都会定义robots.txt文件来限制爬虫爬去信息,我们在爬去网站之前可以使用robots.txt来查看的相关限制信息 例如: 我们以[CSDN博客]的限制信息为例子 在浏览器输入:http ...

  10. 【DB2】NICKNAME报错:SQL0206N "A0.CST_NM" 在使用它的上下文中无效。 SQLSTATE=42703

    1.环境展示: 2.操作描述 现在修改数据库A中CUST_INFO物理表的表结构,新增一个字段为desc varchar(100) ALTER TABLE CUST_INFO DROP COLUMN ...