Given an integer, swap at most one pair of digits to make the largest possible integer.
Example:
43183 -> 83143
Swap 4 and 8.
The key idea is to maximize the number by making a single beneficial swap, if possible. A common approach is to record the last occurrence of each digit, then scan the number from left to right and try to replace each digit with the largest possible digit that appears later. Swapping with the rightmost occurrence of that larger digit yields the best lexicographic improvement. This can be solved in linear time with a digit array or string representation.