Tap here to switch tabs
Problem
Submissions

Problem: Sentence Similarity III

med
30 min
Try to solve the Sentence Similarity III problem.

Statement

You are given two strings sentence1 and sentence2, each representing a sentence composed of words separated by single spaces.

Two sentences are considered similar if you can insert an arbitrary sequence of words (which may be empty) into one of the sentences such that the resulting sentence becomes identical to the other sentence. The inserted words must be separated from the surrounding words by spaces.

Return true if sentence1 and sentence2 are similar, or false otherwise.

Constraints:

  • 1≤1 \leq sentence1.length, sentence2.length ≤100\leq 100

  • sentence1 and sentence2 consist of lowercase and uppercase English letters and spaces.

  • The words in sentence1 and sentence2 are separated by a single space.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Sentence Similarity III

med
30 min
Try to solve the Sentence Similarity III problem.

Statement

You are given two strings sentence1 and sentence2, each representing a sentence composed of words separated by single spaces.

Two sentences are considered similar if you can insert an arbitrary sequence of words (which may be empty) into one of the sentences such that the resulting sentence becomes identical to the other sentence. The inserted words must be separated from the surrounding words by spaces.

Return true if sentence1 and sentence2 are similar, or false otherwise.

Constraints:

  • 1≤1 \leq sentence1.length, sentence2.length ≤100\leq 100

  • sentence1 and sentence2 consist of lowercase and uppercase English letters and spaces.

  • The words in sentence1 and sentence2 are separated by a single space.