Problem 670 · Medium

Maximum Swap

Make a number as large as possible by swapping two of its digits once. The visual scans digits from the right to record the largest later digit and swaps the first smaller digit found.

Open the interactive visualisation