#t201. 句子相似性

句子相似性

Sentence Similarity

Problem Description

A sentence consists of words separated by single spaces, with no extra spaces at the beginning or the end. For example, Hello World, HELLO, and hello world hello world are all sentences. Each word contains only uppercase and lowercase English letters.

Two sentences sentence1 and sentence2 are called similar if you can obtain one sentence by inserting exactly one arbitrary sentence (which may be empty) into the other. For example, sentence1 = Hello my name is Jane and sentence2 = Hello Jane: we can insert my name is between Hello and Jane in sentence2 to get sentence1.

Given two sentences sentence1 and sentence2, if they are similar, return True; otherwise return False.

Input Format

Two lines in total, each containing a sentence as described, of length at most 100100, containing only English letters and spaces.

Output Format

Output the result, True or False.

Sample Input 1

My name is Haley
My Haley

Sample Output 1

True

Sample Input 2

of
A lot of words

Sample Output 2

False

Sample Input 3

Eating right now
Eating

Sample Output 3

True

Sample Input 4

Luky
Lucccky

Sample Output 4

False

Sample Input 5

DN PD
D

Sample Output 5

False

Hint

Explanation 1:

We can insert name is between My and Haley in sentence2 to get sentence1.

Explanation 2:

There is no way to obtain one of the two sentences from the other by inserting just a single sentence.