884. Uncommon Words from Two Sentences Easy
1/**
2 * [884] Uncommon Words from Two Sentences
3 *
4 * A sentence is a string of single-space separated words where each word consists only of lowercase letters.
5 * A word is uncommon if it appears exactly once in one of the sentences, and does not appear in the other sentence.
6 * Given two sentences s1 and s2, return a list of all the uncommon words. You may return the answer in any order.
7 *
8 * Example 1:
9 * Input: s1 = "this apple is sweet", s2 = "this apple is sour"
10 * Output: ["sweet","sour"]
11 * Example 2:
12 * Input: s1 = "apple apple", s2 = "banana"
13 * Output: ["banana"]
14 *
15 * Constraints:
16 *
17 * 1 <= s1.length, s2.length <= 200
18 * s1 and s2 consist of lowercase English letters and spaces.
19 * s1 and s2 do not have leading or trailing spaces.
20 * All the words in s1 and s2 are separated by a single space.
21 *
22 */
23pub struct Solution {}
24
25// problem: https://leetcode.com/problems/uncommon-words-from-two-sentences/
26// discuss: https://leetcode.com/problems/uncommon-words-from-two-sentences/discuss/?currentPage=1&orderBy=most_votes&query=
27
28// submission codes start here
29
30impl Solution {
31 pub fn uncommon_from_sentences(s1: String, s2: String) -> Vec<String> {
32 vec![]
33 }
34}
35
36// submission codes end
37
38#[cfg(test)]
39mod tests {
40 use super::*;
41
42 #[test]
43 fn test_884() {
44 }
45}
46
Back
© 2025 bowen.ge All Rights Reserved.