mirror of
				https://gitee.com/coder-xiaomo/leetcode-problemset
				synced 2025-11-04 11:43:12 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			37 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			37 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
<p>You are given a string <code>word</code>.</p>
 | 
						|
 | 
						|
<p>Return the <strong>maximum</strong> number of non-intersecting <strong><span data-keyword="substring-nonempty">substrings</span></strong> of word that are at <strong>least</strong> four characters long and start and end with the same letter.</p>
 | 
						|
 | 
						|
<p> </p>
 | 
						|
<p><strong class="example">Example 1:</strong></p>
 | 
						|
 | 
						|
<div class="example-block">
 | 
						|
<p><strong>Input:</strong> <span class="example-io">word = "abcdeafdef"</span></p>
 | 
						|
 | 
						|
<p><strong>Output:</strong> <span class="example-io">2</span></p>
 | 
						|
 | 
						|
<p><strong>Explanation:</strong></p>
 | 
						|
 | 
						|
<p>The two substrings are <code>"abcdea"</code> and <code>"fdef"</code>.</p>
 | 
						|
</div>
 | 
						|
 | 
						|
<p><strong class="example">Example 2:</strong></p>
 | 
						|
 | 
						|
<div class="example-block">
 | 
						|
<p><strong>Input:</strong> <span class="example-io">word = "bcdaaaab"</span></p>
 | 
						|
 | 
						|
<p><strong>Output:</strong> <span class="example-io">1</span></p>
 | 
						|
 | 
						|
<p><strong>Explanation:</strong></p>
 | 
						|
 | 
						|
<p>The only substring is <code>"aaaa"</code>. Note that we cannot <strong>also</strong> choose <code>"bcdaaaab"</code> since it intersects with the other substring.</p>
 | 
						|
</div>
 | 
						|
 | 
						|
<p> </p>
 | 
						|
<p><strong>Constraints:</strong></p>
 | 
						|
 | 
						|
<ul>
 | 
						|
	<li><code>1 <= word.length <= 2 * 10<sup>5</sup></code></li>
 | 
						|
	<li><code>word</code> consists only of lowercase English letters.</li>
 | 
						|
</ul>
 |