Maximum Swap

Medium · Greedy · about 15 minutes

Asked at Meta, Google, Amazon, ByteDance.

Given a non-negative integer num, you may swap two of its digits at most once. Return the largest number you can get.