mirror of
				https://gitee.com/coder-xiaomo/leetcode-problemset
				synced 2025-11-04 19:53:12 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			41 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			41 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
<p>给你一个仅由数字 6 和 9 组成的正整数 <code>num</code>。</p>
 | 
						||
 | 
						||
<p>你最多只能翻转一位数字,将 6 变成 9,或者把 9 变成 6 。</p>
 | 
						||
 | 
						||
<p>请返回你可以得到的最大数字。</p>
 | 
						||
 | 
						||
<p> </p>
 | 
						||
 | 
						||
<p><strong>示例 1:</strong></p>
 | 
						||
 | 
						||
<pre><strong>输入:</strong>num = 9669
 | 
						||
<strong>输出:</strong>9969
 | 
						||
<strong>解释:</strong>
 | 
						||
改变第一位数字可以得到 6669 。
 | 
						||
改变第二位数字可以得到 9969 。
 | 
						||
改变第三位数字可以得到 9699 。
 | 
						||
改变第四位数字可以得到 9666 。
 | 
						||
其中最大的数字是 9969 。
 | 
						||
</pre>
 | 
						||
 | 
						||
<p><strong>示例 2:</strong></p>
 | 
						||
 | 
						||
<pre><strong>输入:</strong>num = 9996
 | 
						||
<strong>输出:</strong>9999
 | 
						||
<strong>解释:</strong>将最后一位从 6 变到 9,其结果 9999 是最大的数。</pre>
 | 
						||
 | 
						||
<p><strong>示例 3:</strong></p>
 | 
						||
 | 
						||
<pre><strong>输入:</strong>num = 9999
 | 
						||
<strong>输出:</strong>9999
 | 
						||
<strong>解释:</strong>无需改变就已经是最大的数字了。</pre>
 | 
						||
 | 
						||
<p> </p>
 | 
						||
 | 
						||
<p><strong>提示:</strong></p>
 | 
						||
 | 
						||
<ul>
 | 
						||
	<li><code>1 <= num <= 10^4</code></li>
 | 
						||
	<li><code>num</code> 每一位上的数字都是 6 或者 9 。</li>
 | 
						||
</ul>
 |