poj 1936 贪心(s串是否为t的子串)
来源:互联网 发布:ios 模仿淘宝地址选择 编辑:程序博客网 时间:2024/05/22 04:34
题意:给定两个字符串s和t,问s是否为t的子串。
思路:算法设计第4章习题4。直接贪心即可,复杂度O(len(s)+len(t))。
#include <stdio.h>#include <string.h>#define N 100005char s[N],t[N];int main(){ while(scanf("%s %s",s,t)!=EOF){ int i,j,lens,lent; lens = strlen(s); lent = strlen(t); for(i = j = 0;i<lens&&j<lent;j++) if(s[i] == t[j]) i++; if(i == lens) printf("Yes\n"); else printf("No\n"); }}
0 0
- poj 1936 贪心(s串是否为t的子串)
- nyoj847 S + T(贪心)
- 判断一个字符串是否为另一个字符串的子串
- 检查一个单词是否为其他字符串的子串
- 1.8 判断是否为旋转子串
- 判断是否为其子串
- 从串s中删除所有和串t相同的子串的算法
- 『算法』求串s和串t的最大公约子串
- POJ 3069 Saruman's Army(水题,简单的贪心)
- poj 1936 求一个串 是否为 另一个的自串(可以不连续)
- POJ - Saruman's Army(贪心)
- poj 3069 Saruman's Army(贪心)
- POJ 3069 Saruman's Army (贪心)
- POJ 3069 - Saruman's Army(贪心)
- POJ 3069 Saruman's Army (贪心)
- POJ 3069 Saruman's Army(贪心)
- POJ 3069 Saruman's Army(贪心)
- POJ 3069.Saruman's Army(贪心)
- 1075.PAT Judge
- 1076.Forwards on Weibo
- #286 (Div. 2) C. Mr. Kitayuta, the Treasure Hunter
- POJ 2485 Highways 最小生成树 prim算法
- 为什么数据库要有主键
- poj 1936 贪心(s串是否为t的子串)
- 几种启动方式
- Linux块设备驱动程序原理
- 链接 autolink
- Linux安装mysql
- IDEA 环境常用设置整理
- iOS开发-内存管理
- 算法——利用Trie树统计某种前缀的单词的个数
- XML的四种解析方式