```
def maximumSwap(self, num):
a = list(str(num))
n = len(a)
for i in range(n):
curmax = float('-inf')
for ind, val in enumerate(a[i:]):
if curmax <= val: indmax, curmax = ind, val
if a[i] != curmax:
a[i], a[i+indmax] = curmax, a[i]
break
return int(''.join(a))
```