UVA10340子序列
题意:
给你两个串,问你第二个第一个串是否是第一个串删除0个或多个字母得到的?
思路:
直接模拟就行了,在第二个串中去按顺序更新第一个串的下标,好像没说明白啊,不管了,水题,不理解直接看下代码就懂了。
#include<stdio.h>
#include<string.h>
char str1[1100000] ,str2[1100000];
int main ()
{
while(~scanf("%s %s" ,str1 ,str2))
{
int l1 = strlen(str1);
int l2 = strlen(str2);
if(l1 > l2)
{
puts("No");
continue;
}
int nowid = 0;
for(int i = 0 ;i < l2 ;i ++)
{
if(str2[i] == str1[nowid])
nowid ++;
if(nowid == l1) break;
}
nowid == l1 ? puts("Yes") : puts("No");
}
return 0;
}
UVA10340子序列的更多相关文章
- 子序列 (All in All,UVa10340)
题目描述:算法竞赛入门经典习题3-9 题目思路:循环匹配 //没有按照原题的输入输出 #include <stdio.h> #include <string.h> #defin ...
- 用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,如果分别是两个或多个已知数列的子序列,且是所有符合此条件序列中最长的,则 ...
随机推荐
- HTML5基础入门一天学完
HTML 什么是HTML HTML:Hyper Text Markup Language(超文本编辑语言) HTML的发展史 HTML5优势 世界知名浏览器厂商对HTML5的支持 市场的需求 跨平台 ...
- DataFocus小学堂|客户分析之复活客户分析
复活客户分析 什么是"复活客户"?如何进行"复活客户分析"呢?今天,我们借助DataFocus系统,来了解一种简单的复活客户分析. 1.何为复活客户 复活客户, ...
- P4847 银河英雄传说V2 题解(Splay)
题目链接 P4847 银河英雄传说V2 解题思路 我天哪!!!\(splay\)在\(rotate\)的时候先\(upd(y)\)再\(upd(x)\)!!以后不能再因为这个\(WA\)一晚上了!!! ...
- dk.exe自动填报程序的反编译
dk.exe自动填报程序的反编译 dk.exe用于学校每日健康报的自动填写.
- JAVA-常用集合类型转换例子
package com.net.xinfang.reflect; import java.util.ArrayList; import java.util.Arrays; import java.ut ...
- CSS-clear属性的作用
1 <!DOCTYPE html> 2 <html lang="en"> 3 <head> 4 <meta charset="U ...
- 冒泡排序算法的实现(Java)
什么是冒泡排序 冒泡排序(Bubble Sort),是一种计算机科学领域的较简单的排序算法.它重复地走访过要排序的元素列,依次比较两个相邻的元素,如果顺序(如从大到小.首字母从Z到A)错误就把他们交换 ...
- 攻防世界 reverse seven
seven hctf2018 这是一个驱动文件 ida载入,查找字符串 根据字符串来到函数:sub_1400012F0 __int64 __fastcall sub_1400012F0(__int6 ...
- APIView里如何获取HTTP里的数据
request.data.get() 获取post方法表单里的数据 request.post.get() 获取post方法表单里的数据 request.GET.get() 获取URL里的数据 r ...
- java例题_01 不死神兔!
1 /*1 [程序 1 不死神兔] 2 题目:古典问题:有一对兔子,从出生后第 3 个月起每个月都生一对兔子,小兔子长到第三个月后每个月又生一对兔子,假如兔子都不死,问每个月的兔子对数为多少? 3 程 ...