mirror of
				https://gitee.com/coder-xiaomo/leetcode-problemset
				synced 2025-11-04 11:43:12 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			33 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			33 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
<p>给你一个正整数 <code>num</code> 。你可以交换 <code>num</code> 中 <strong>奇偶性</strong> 相同的任意两位数字(即,都是奇数或者偶数)。</p>
 | 
						||
 | 
						||
<p>返回交换 <strong>任意</strong> 次之后 <code>num</code> 的 <strong>最大</strong> 可能值<em>。</em></p>
 | 
						||
 | 
						||
<p> </p>
 | 
						||
 | 
						||
<p><strong>示例 1:</strong></p>
 | 
						||
 | 
						||
<pre><strong>输入:</strong>num = 1234
 | 
						||
<strong>输出:</strong>3412
 | 
						||
<strong>解释:</strong>交换数字 3 和数字 1 ,结果得到 3214 。
 | 
						||
交换数字 2 和数字 4 ,结果得到 3412 。
 | 
						||
注意,可能存在其他交换序列,但是可以证明 3412 是最大可能值。
 | 
						||
注意,不能交换数字 4 和数字 1 ,因为它们奇偶性不同。
 | 
						||
</pre>
 | 
						||
 | 
						||
<p><strong>示例 2:</strong></p>
 | 
						||
 | 
						||
<pre><strong>输入:</strong>num = 65875
 | 
						||
<strong>输出:</strong>87655
 | 
						||
<strong>解释:</strong>交换数字 8 和数字 6 ,结果得到 85675 。
 | 
						||
交换数字 5 和数字 7 ,结果得到 87655 。
 | 
						||
注意,可能存在其他交换序列,但是可以证明 87655 是最大可能值。
 | 
						||
</pre>
 | 
						||
 | 
						||
<p> </p>
 | 
						||
 | 
						||
<p><strong>提示:</strong></p>
 | 
						||
 | 
						||
<ul>
 | 
						||
	<li><code>1 <= num <= 10<sup>9</sup></code></li>
 | 
						||
</ul>
 |