mirror of
				https://gitee.com/coder-xiaomo/leetcode-problemset
				synced 2025-11-04 03:33:12 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			29 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			29 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
<p>Given a string <code>s</code>, reverse the string according to the following rules:</p>
 | 
						|
 | 
						|
<ul>
 | 
						|
	<li>All the characters that are not English letters remain in the same position.</li>
 | 
						|
	<li>All the English letters (lowercase or uppercase) should be reversed.</li>
 | 
						|
</ul>
 | 
						|
 | 
						|
<p>Return <code>s</code><em> after reversing it</em>.</p>
 | 
						|
 | 
						|
<p> </p>
 | 
						|
<p><strong>Example 1:</strong></p>
 | 
						|
<pre><strong>Input:</strong> s = "ab-cd"
 | 
						|
<strong>Output:</strong> "dc-ba"
 | 
						|
</pre><p><strong>Example 2:</strong></p>
 | 
						|
<pre><strong>Input:</strong> s = "a-bC-dEf-ghIj"
 | 
						|
<strong>Output:</strong> "j-Ih-gfE-dCba"
 | 
						|
</pre><p><strong>Example 3:</strong></p>
 | 
						|
<pre><strong>Input:</strong> s = "Test1ng-Leet=code-Q!"
 | 
						|
<strong>Output:</strong> "Qedo1ct-eeLg=ntse-T!"
 | 
						|
</pre>
 | 
						|
<p> </p>
 | 
						|
<p><strong>Constraints:</strong></p>
 | 
						|
 | 
						|
<ul>
 | 
						|
	<li><code>1 <= s.length <= 100</code></li>
 | 
						|
	<li><code>s</code> consists of characters with ASCII values in the range <code>[33, 122]</code>.</li>
 | 
						|
	<li><code>s</code> does not contain <code>'\"'</code> or <code>'\\'</code>.</li>
 | 
						|
</ul>
 |