670. Maximum Swap

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:

Example 2:

Note:

  1. The given number is in the range [0, 108]

 

Leave a Reply

Your email address will not be published. Required fields are marked *