mirror of
				https://gitee.com/coder-xiaomo/leetcode-problemset
				synced 2025-11-04 11:43:12 +08:00 
			
		
		
		
	add scripts and problemset
This commit is contained in:
		
							
								
								
									
										34
									
								
								算法题/substrings-of-size-three-with-distinct-characters.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								算法题/substrings-of-size-three-with-distinct-characters.html
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,34 @@
 | 
			
		||||
<p>A string is <strong>good</strong> if there are no repeated characters.</p>
 | 
			
		||||
 | 
			
		||||
<p>Given a string <code>s</code>, return <em>the number of <strong>good substrings</strong> of length <strong>three </strong>in </em><code>s</code>.</p>
 | 
			
		||||
 | 
			
		||||
<p>Note that if there are multiple occurrences of the same substring, every occurrence should be counted.</p>
 | 
			
		||||
 | 
			
		||||
<p>A <strong>substring</strong> is a contiguous sequence of characters in a string.</p>
 | 
			
		||||
 | 
			
		||||
<p> </p>
 | 
			
		||||
<p><strong>Example 1:</strong></p>
 | 
			
		||||
 | 
			
		||||
<pre>
 | 
			
		||||
<strong>Input:</strong> s = "xyzzaz"
 | 
			
		||||
<strong>Output:</strong> 1
 | 
			
		||||
<strong>Explanation:</strong> There are 4 substrings of size 3: "xyz", "yzz", "zza", and "zaz". 
 | 
			
		||||
The only good substring of length 3 is "xyz".
 | 
			
		||||
</pre>
 | 
			
		||||
 | 
			
		||||
<p><strong>Example 2:</strong></p>
 | 
			
		||||
 | 
			
		||||
<pre>
 | 
			
		||||
<strong>Input:</strong> s = "aababcabc"
 | 
			
		||||
<strong>Output:</strong> 4
 | 
			
		||||
<strong>Explanation:</strong> There are 7 substrings of size 3: "aab", "aba", "bab", "abc", "bca", "cab", and "abc".
 | 
			
		||||
The good substrings are "abc", "bca", "cab", and "abc".
 | 
			
		||||
</pre>
 | 
			
		||||
 | 
			
		||||
<p> </p>
 | 
			
		||||
<p><strong>Constraints:</strong></p>
 | 
			
		||||
 | 
			
		||||
<ul>
 | 
			
		||||
	<li><code>1 <= s.length <= 100</code></li>
 | 
			
		||||
	<li><code>s</code> consists of lowercase English letters.</li>
 | 
			
		||||
</ul>
 | 
			
		||||
		Reference in New Issue
	
	Block a user