Each input is a nonempty sentence made of English-letter words separated by single spaces, with no leading or trailing space. Return true if inserting one contiguous group of whole words into either sentence can make the two sentences identical. You may insert at the beginning, between words, or at the end, and the inserted group may be empty. Comparisons are case-sensitive; you cannot split a word or insert at multiple separate positions.
Example 1:
Input: sentence1 = "We code daily"
sentence2 = "We daily"
Output: trueExplanation: Insert the word code between We and daily in the second sentence to make the sentences equal.
Example 2:
Input: sentence1 = "cat"
sentence2 = "cats"
Output: falseExplanation: The word cat cannot become cats by inserting whole words separated by spaces. Partial-word insertion is not allowed.
Example 3:
Input: sentence1 = "A B C"
sentence2 = "B"
Output: falseExplanation: Turning B into A B C requires adding words at both ends. That needs two separate insertion positions, so the sentences are not similar.
Constraints:
1 <= sentence1.length, sentence2.length <= 100- Each sentence contains only uppercase and lowercase English letters and spaces.
- Words are separated by a single space, with no leading or trailing spaces.