mirror of
				https://gitee.com/coder-xiaomo/leetcode-problemset
				synced 2025-11-04 19:53:12 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			28 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			28 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
<p>Given a <strong>positive</strong> integer <code>num</code> represented as a string, return <em>the integer </em><code>num</code><em> without trailing zeros as a string</em>.</p>
 | 
						|
 | 
						|
<p> </p>
 | 
						|
<p><strong class="example">Example 1:</strong></p>
 | 
						|
 | 
						|
<pre>
 | 
						|
<strong>Input:</strong> num = "51230100"
 | 
						|
<strong>Output:</strong> "512301"
 | 
						|
<strong>Explanation:</strong> Integer "51230100" has 2 trailing zeros, we remove them and return integer "512301".
 | 
						|
</pre>
 | 
						|
 | 
						|
<p><strong class="example">Example 2:</strong></p>
 | 
						|
 | 
						|
<pre>
 | 
						|
<strong>Input:</strong> num = "123"
 | 
						|
<strong>Output:</strong> "123"
 | 
						|
<strong>Explanation:</strong> Integer "123" has no trailing zeros, we return integer "123".
 | 
						|
</pre>
 | 
						|
 | 
						|
<p> </p>
 | 
						|
<p><strong>Constraints:</strong></p>
 | 
						|
 | 
						|
<ul>
 | 
						|
	<li><code>1 <= num.length <= 1000</code></li>
 | 
						|
	<li><code>num</code> consists of only digits.</li>
 | 
						|
	<li><code>num</code> doesn't have any leading zeros.</li>
 | 
						|
</ul>
 |