mirror of
				https://gitee.com/coder-xiaomo/leetcode-problemset
				synced 2025-11-04 11:43:12 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			40 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			40 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
<p>There is a malfunctioning keyboard where some letter keys do not work. All other keys on the keyboard work properly.</p>
 | 
						|
 | 
						|
<p>Given a string <code>text</code> of words separated by a single space (no leading or trailing spaces) and a string <code>brokenLetters</code> of all <strong>distinct</strong> letter keys that are broken, return <em>the <strong>number of words</strong> in</em> <code>text</code> <em>you can fully type using this keyboard</em>.</p>
 | 
						|
 | 
						|
<p> </p>
 | 
						|
<p><strong>Example 1:</strong></p>
 | 
						|
 | 
						|
<pre>
 | 
						|
<strong>Input:</strong> text = "hello world", brokenLetters = "ad"
 | 
						|
<strong>Output:</strong> 1
 | 
						|
<strong>Explanation:</strong> We cannot type "world" because the 'd' key is broken.
 | 
						|
</pre>
 | 
						|
 | 
						|
<p><strong>Example 2:</strong></p>
 | 
						|
 | 
						|
<pre>
 | 
						|
<strong>Input:</strong> text = "leet code", brokenLetters = "lt"
 | 
						|
<strong>Output:</strong> 1
 | 
						|
<strong>Explanation:</strong> We cannot type "leet" because the 'l' and 't' keys are broken.
 | 
						|
</pre>
 | 
						|
 | 
						|
<p><strong>Example 3:</strong></p>
 | 
						|
 | 
						|
<pre>
 | 
						|
<strong>Input:</strong> text = "leet code", brokenLetters = "e"
 | 
						|
<strong>Output:</strong> 0
 | 
						|
<strong>Explanation:</strong> We cannot type either word because the 'e' key is broken.
 | 
						|
</pre>
 | 
						|
 | 
						|
<p> </p>
 | 
						|
<p><strong>Constraints:</strong></p>
 | 
						|
 | 
						|
<ul>
 | 
						|
	<li><code>1 <= text.length <= 10<sup>4</sup></code></li>
 | 
						|
	<li><code>0 <= brokenLetters.length <= 26</code></li>
 | 
						|
	<li><code>text</code> consists of words separated by a single space without any leading or trailing spaces.</li>
 | 
						|
	<li>Each word only consists of lowercase English letters.</li>
 | 
						|
	<li><code>brokenLetters</code> consists of <strong>distinct</strong> lowercase English letters.</li>
 | 
						|
</ul>
 |