String practice 1
Submit solution
C, C++, Python3
Points:
1
Time limit:
1.0s
Memory limit:
64M
Author:
Problem type
Allowed languages
This practice problem will require you to programme basic string operations.
If you are using C++, it is recommended that you use C++ string
but C styled Char Array is also
fine. If you are using Python, please keep reading.
Your task is to compare 2 strings, and figure out if the second string is a substring of the first.
Input Specification
The first line will contain an integer \(N\) (\(1 < N < 200\)), indicating the number of cases.
The following \(N\) lines will each contain 2 strings separated by whitespace. These 2 strings will not contain whitespace internally. Each string will not be longer than 200 characters.
Output Specification
The output should contain \(N\) lines, each line either Yes
or No
, indicating
whether the second string is a substring of the first.
Sample Input
2
Hello world!
HelloWorld! Hello
Sample Output
No
Yes
Comments
In Python, if you have 2 string
str1
andstr2
, and you want to know ifstr2
is a substring ofstr1
, you can simply use the expressionThe expression
str2 in str1
will return to you abool
value of eitherTrue
orFalse