Medium · Math

Maximum Swap

Given an integer num in [0, 10⁸], return the largest number you can get by swapping two of its digits at most once.

Examples

Example 1

{
  "num": 2736
}

Output: 7236

Example 2

{
  "num": 9973
}

Output: 9973

Rebuild it in the studio

Open every published interview problem, solution, scene, and memory room free, with no account.

More Math problems