题目描述
Given a non-negative integer, you could swap two digits at most once to get the maximum valued number. Return the maximum valued number you could get.
Example 1:
Input: 2736
Output: 7236
Explanation: Swap the number 2 and the number 7.
Example 2:
Input: 9973
Output: 9973
Explanation: No swap.
Note:
The given number is in the range [0, 1 0 8 10^8 108]
题目分析
一开始我只考虑了交换第一个数与后面的最大数交换的情况。结果,比如说98