Practice Maximum Swap
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
You are given an integer num. You can swap two digits at most once to get the maximum valued number. Return the maximum valued number you can get.
Source: Maximum Swap on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
num = 2736
Output
7236
# Example 2
Input
num = 9973
Output
9973
Constraints
0 <= num <= 10^8
Related LeetCode Problems
Practice more problems similar to Maximum Swap.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.