Package g0601_0700.s0670_maximum_swap
Class Solution
java.lang.Object
g0601_0700.s0670_maximum_swap.Solution
670 - Maximum Swap.<p>Medium</p>
<p>You are given an integer <code>num</code>. You can swap two digits at most once to get the maximum valued number.</p>
<p>Return <em>the maximum valued number you can get</em>.</p>
<p><strong>Example 1:</strong></p>
<p><strong>Input:</strong> num = 2736</p>
<p><strong>Output:</strong> 7236</p>
<p><strong>Explanation:</strong> Swap the number 2 and the number 7.</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> num = 9973</p>
<p><strong>Output:</strong> 9973</p>
<p><strong>Explanation:</strong> No swap.</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>0 <= num <= 10<sup>8</sup></code></li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
maximumSwap
public int maximumSwap(int num)
-