1813. Sentence Similarity III Medium

@problem@discussion
#Array#Two Pointers#String



1/**
2 * [1813] Sentence Similarity III
3 *
4 * A sentence is a list of words that are separated by a single space with no leading or trailing spaces. For example, "Hello World", "HELLO", "hello world hello world" are all sentences. Words consist of only uppercase and lowercase English letters.
5 * Two sentences sentence1 and sentence2 are similar if it is possible to insert an arbitrary sentence (possibly empty) inside one of these sentences such that the two sentences become equal. For example, sentence1 = "Hello my name is Jane" and sentence2 = "Hello Jane" can be made equal by inserting "my name is" between "Hello" and "Jane" in sentence2.
6 * Given two sentences sentence1 and sentence2, return true if sentence1 and sentence2 are similar. Otherwise, return false.
7 *  
8 * Example 1:
9 * 
10 * Input: sentence1 = "My name is Haley", sentence2 = "My Haley"
11 * Output: true
12 * Explanation: sentence2 can be turned to sentence1 by inserting "name is" between "My" and "Haley".
13 * 
14 * Example 2:
15 * 
16 * Input: sentence1 = "of", sentence2 = "A lot of words"
17 * Output: false
18 * Explanation: No single sentence can be inserted inside one of the sentences to make it equal to the other.
19 * 
20 * Example 3:
21 * 
22 * Input: sentence1 = "Eating right now", sentence2 = "Eating"
23 * Output: true
24 * Explanation: sentence2 can be turned to sentence1 by inserting "right now" at the end of the sentence.
25 * 
26 *  
27 * Constraints:
28 * 
29 * 	1 <= sentence1.length, sentence2.length <= 100
30 * 	sentence1 and sentence2 consist of lowercase and uppercase English letters and spaces.
31 * 	The words in sentence1 and sentence2 are separated by a single space.
32 * 
33 */
34pub struct Solution {}
35
36// problem: https://leetcode.com/problems/sentence-similarity-iii/
37// discuss: https://leetcode.com/problems/sentence-similarity-iii/discuss/?currentPage=1&orderBy=most_votes&query=
38
39// submission codes start here
40
41impl Solution {
42    pub fn are_sentences_similar(sentence1: String, sentence2: String) -> bool {
43        false
44    }
45}
46
47// submission codes end
48
49#[cfg(test)]
50mod tests {
51    use super::*;
52
53    #[test]
54    fn test_1813() {
55    }
56}
57


Back
© 2025 bowen.ge All Rights Reserved.