Uvs: 10340

Source: Internet
Author: User

Question: 10340-All in All


Returns the string s and t and asks if s is a substring of t. If the characters removed by s can be the same as t, t is a substring of s.


Solution: Match characters. Each character of t matches the character in s. Note that the size of the character array must be greater.


Code:

# Include <stdio. h> # include <string. h> const int N = 1000005; char s [N], t [N]; bool match () {int I = 0; int lens = strlen (s ); int lent = strlen (t); for (int j = 0; j <lent; j ++) {if (I = lens) return true; if (lens-I> lent-j) return false; if (s [I] = t [j]) I ++;} if (I = lens) return true; return false;} int main () {while (scanf ("% s", s )! = EOF) {scanf ("% s", t); printf ("% s \ n", match ()? "Yes": "No");} return 0 ;}


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.