mirror of
				https://gitee.com/coder-xiaomo/leetcode-problemset
				synced 2025-11-04 11:43:12 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			37 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			37 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
<p>A <strong>sentence</strong> is a string of single-space separated words where each word consists only of lowercase letters.</p>
 | 
						|
 | 
						|
<p>A word is <strong>uncommon</strong> if it appears exactly once in one of the sentences, and <strong>does not appear</strong> in the other sentence.</p>
 | 
						|
 | 
						|
<p>Given two <strong>sentences</strong> <code>s1</code> and <code>s2</code>, return <em>a list of all the <strong>uncommon words</strong></em>. You may return the answer in <strong>any order</strong>.</p>
 | 
						|
 | 
						|
<p> </p>
 | 
						|
<p><strong class="example">Example 1:</strong></p>
 | 
						|
 | 
						|
<div class="example-block">
 | 
						|
<p><strong>Input:</strong> <span class="example-io">s1 = "this apple is sweet", s2 = "this apple is sour"</span></p>
 | 
						|
 | 
						|
<p><strong>Output:</strong> <span class="example-io">["sweet","sour"]</span></p>
 | 
						|
 | 
						|
<p><strong>Explanation:</strong></p>
 | 
						|
 | 
						|
<p>The word <code>"sweet"</code> appears only in <code>s1</code>, while the word <code>"sour"</code> appears only in <code>s2</code>.</p>
 | 
						|
</div>
 | 
						|
 | 
						|
<p><strong class="example">Example 2:</strong></p>
 | 
						|
 | 
						|
<div class="example-block">
 | 
						|
<p><strong>Input:</strong> <span class="example-io">s1 = "apple apple", s2 = "banana"</span></p>
 | 
						|
 | 
						|
<p><strong>Output:</strong> <span class="example-io">["banana"]</span></p>
 | 
						|
</div>
 | 
						|
 | 
						|
<p> </p>
 | 
						|
<p><strong>Constraints:</strong></p>
 | 
						|
 | 
						|
<ul>
 | 
						|
	<li><code>1 <= s1.length, s2.length <= 200</code></li>
 | 
						|
	<li><code>s1</code> and <code>s2</code> consist of lowercase English letters and spaces.</li>
 | 
						|
	<li><code>s1</code> and <code>s2</code> do not have leading or trailing spaces.</li>
 | 
						|
	<li>All the words in <code>s1</code> and <code>s2</code> are separated by a single space.</li>
 | 
						|
</ul>
 |