mirror of
				https://gitee.com/coder-xiaomo/leetcode-problemset
				synced 2025-11-04 11:43:12 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			24 lines
		
	
	
		
			801 B
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			24 lines
		
	
	
		
			801 B
		
	
	
	
		
			HTML
		
	
	
	
	
	
<p>Write a method to replace all spaces in a string with '%20'. You may assume that the string has sufficient space at the end to hold the additional characters,and that you are given the "true" length of the string. (Note: If implementing in Java,please use a character array so that you can perform this operation in place.)</p>
 | 
						|
 | 
						|
<p><strong>Example 1:</strong></p>
 | 
						|
 | 
						|
<pre>
 | 
						|
<strong>Input: </strong>"Mr John Smith ", 13
 | 
						|
<strong>Output: </strong>"Mr%20John%20Smith"
 | 
						|
</pre>
 | 
						|
 | 
						|
<p><strong>Example 2:</strong></p>
 | 
						|
 | 
						|
<pre>
 | 
						|
<strong>Input: </strong>"               ", 5
 | 
						|
<strong>Output: </strong>"%20%20%20%20%20"
 | 
						|
</pre>
 | 
						|
 | 
						|
<p> </p>
 | 
						|
 | 
						|
<p><strong>Note:</strong></p>
 | 
						|
 | 
						|
<ol>
 | 
						|
	<li><code>0 <= S.length <= 500000</code></li>
 | 
						|
</ol>
 |