leetcode_670. Maximum Swap ? 待解决

来源:互联网 发布:东方project mac版 编辑:程序博客网 时间:2024/06/01 16:38

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, 108]

提示:提交代码后,需要用简洁的语言解释一下代码思路~ 谢谢

历史题目和总结见公众号「每日一道算法题」

https://leetcode.com/problems/maximum-swap/description/

思路

原创粉丝点击