Tap here to switch tabs
Problem
Submissions

Problem: Maximum Swap

Maximum Swap asks you to rearrange the digits of a nonnegative integer by making at most one swap, then return the largest number possible.

Statement

Given an integer num, return the maximum number that can be formed by swapping at most two digits once.

Constraints:

  • 0≤0 \leq num ≤105\leq 10^5

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Maximum Swap

Maximum Swap asks you to rearrange the digits of a nonnegative integer by making at most one swap, then return the largest number possible.

Statement

Given an integer num, return the maximum number that can be formed by swapping at most two digits once.

Constraints:

  • 0≤0 \leq num ≤105\leq 10^5