子序列 (All in All,UVa10340)
题目描述:算法竞赛入门经典习题3-9

题目思路:循环匹配
//没有按照原题的输入输出
#include <stdio.h>
#include <string.h>
#define maxn 100
int main(int argc, char *argv[])
{
char s[maxn],t[maxn] ;
scanf("%s%s",s,t) ;
int tlen = strlen(t) ;
int slen = strlen(s);
int k = ,j=;
for(int i=;i<tlen;i++){ while(j<slen){
if(t[i] == s[j]){
k++ ;
j++ ;
break ;
}
j++ ;
}
}
if(k == tlen) printf("YES\n") ;
return ;
}
子序列 (All in All,UVa10340)的更多相关文章
- UVA10340子序列
题意: 给你两个串,问你第二个第一个串是否是第一个串删除0个或多个字母得到的? 思路: 直接模拟就行了,在第二个串中去按顺序更新第一个串的下标,好像没说明白啊,不管了,水题,不 ...
- 用python实现最长公共子序列算法(找到所有最长公共子串)
软件安全的一个小实验,正好复习一下LCS的写法. 实现LCS的算法和算法导论上的方式基本一致,都是先建好两个表,一个存储在(i,j)处当前最长公共子序列长度,另一个存储在(i,j)处的回溯方向. 相对 ...
- codevs 1576 最长上升子序列的线段树优化
题目:codevs 1576 最长严格上升子序列 链接:http://codevs.cn/problem/1576/ 优化的地方是 1到i-1 中最大的 f[j]值,并且A[j]<A[i] .根 ...
- [LeetCode] Arithmetic Slices II - Subsequence 算数切片之二 - 子序列
A sequence of numbers is called arithmetic if it consists of at least three elements and if the diff ...
- [LeetCode] Is Subsequence 是子序列
Given a string s and a string t, check if s is subsequence of t. You may assume that there is only l ...
- [LeetCode] Wiggle Subsequence 摆动子序列
A sequence of numbers is called a wiggle sequence if the differences between successive numbers stri ...
- [LeetCode] Increasing Triplet Subsequence 递增的三元子序列
Given an unsorted array return whether an increasing subsequence of length 3 exists or not in the ar ...
- [LeetCode] Distinct Subsequences 不同的子序列
Given a string S and a string T, count the number of distinct subsequences of T in S. A subsequence ...
- 动态规划之最长公共子序列(LCS)
转自:http://segmentfault.com/blog/exploring/ LCS 问题描述 定义: 一个数列 S,如果分别是两个或多个已知数列的子序列,且是所有符合此条件序列中最长的,则 ...
随机推荐
- js去除空格(trim方法)
/** * 去空格 */ String.prototype.trim=function(){ return this.replace(/(^\s*)|(\s*$)/g, ""); ...
- MVC导航菜单高亮显示实现思路
///代码不是我写的,但是已经亲自测试过了,按照我的理解写的注释,不对的地方大家评论指出 @{ @*这个是把当前的路由值格式化并保存到currentController这个变量中,这里是格式化为Con ...
- c++中如 <类名 类名::对象> 是什么意思
CComplex CComplex::add(CComplex &x) (这一句 不懂为何 类名 类名::对象) { CComplex y(real+x.real,image+x.image) ...
- plsql误删除数据,提交事务后如何找回?
select * from tbs_rep_template as of timestamp to_timestamp('2018-07-12 14:23:00', 'yyyy-mm-dd hh24: ...
- redhat6本地源NBD驱动安装
安装NBD驱动 一.配置本地yum源 1.挂载系统安装光盘 # mount /dev/cdrom /mnt/cdrom/ # mkdir /mnt/media # cp -rf /mnt/cdrom/ ...
- iOS11.2-11.3.1进行越狱及问题
设备环境:Electra.iOS11.13.1 PS:Electra最新版本进行越狱只支持11.14以下的版本.同时这是不完美越狱,每次重启手机都需要重新越狱,最后,由于Electra版本推出仓促,一 ...
- 使用第三方库iOS-ECharts做柱状图的心得
最近的项目里面用到了饼图和条形统计图,饼图用的是PNChart来做的,这个库感觉用起来也简单,但是做条形统计图的时候就特别蛋疼(不知道是不是我姿势没对),反正就是各种问题,然后就想到换一种框架,最后选 ...
- 聊聊c#与Python以及IronPython
简单说说这个意义.做了很久的c#,突然发现Python火了.就看看,估计这篇博文有点长,有点长,尽量包括主要的东西,还有点杂,浏览吧,选择自己喜欢的看看. 先看比较.网上一堆各种比较.但是主要比较语法 ...
- Mac连接Linux服务器
1.终端命令 a).打开Mac的命令终端 b).输入ssh -p 22 root@101.200.86.233 它会提示你输入密码,输入正确的密码之后,你就发现已经登陆成功了.(22: 端口号 roo ...
- Python入门 —— 06语音识别
Python 语音 实现语音操控的原理 语音操控分为语音识别和语音朗读两部分 我们使用speech模块实现语音模块(python 2.7) SAPI是微软Speech API , 是微软公司推出的语音 ...