mirror of
				https://gitee.com/coder-xiaomo/leetcode-problemset
				synced 2025-11-04 11:43:12 +08:00 
			
		
		
		
	国外版
This commit is contained in:
		
							
								
								
									
										20
									
								
								算法题(国外版)/reverse-string-ii.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								算法题(国外版)/reverse-string-ii.html
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,20 @@
 | 
			
		||||
<p>Given a string <code>s</code> and an integer <code>k</code>, reverse the first <code>k</code> characters for every <code>2k</code> characters counting from the start of the string.</p>
 | 
			
		||||
 | 
			
		||||
<p>If there are fewer than <code>k</code> characters left, reverse all of them. If there are less than <code>2k</code> but greater than or equal to <code>k</code> characters, then reverse the first <code>k</code> characters and leave the other as original.</p>
 | 
			
		||||
 | 
			
		||||
<p> </p>
 | 
			
		||||
<p><strong>Example 1:</strong></p>
 | 
			
		||||
<pre><strong>Input:</strong> s = "abcdefg", k = 2
 | 
			
		||||
<strong>Output:</strong> "bacdfeg"
 | 
			
		||||
</pre><p><strong>Example 2:</strong></p>
 | 
			
		||||
<pre><strong>Input:</strong> s = "abcd", k = 2
 | 
			
		||||
<strong>Output:</strong> "bacd"
 | 
			
		||||
</pre>
 | 
			
		||||
<p> </p>
 | 
			
		||||
<p><strong>Constraints:</strong></p>
 | 
			
		||||
 | 
			
		||||
<ul>
 | 
			
		||||
	<li><code>1 <= s.length <= 10<sup>4</sup></code></li>
 | 
			
		||||
	<li><code>s</code> consists of only lowercase English letters.</li>
 | 
			
		||||
	<li><code>1 <= k <= 10<sup>4</sup></code></li>
 | 
			
		||||
</ul>
 | 
			
		||||
		Reference in New Issue
	
	Block a user