There is nothing more beautiful than just an integer number.
You are given an integer n. Write down n in decimal notation with no leading zeroes, and let M be the number of written digits. Perform the following operation exactly k times:
- Choose two different 1-based positions, i and j, such that 1 <= i < j <= M. Swap the digits at positions i and j. This swap must not cause the resulting number to have a leading zero, i.e., if the digit at position j is zero, then i must be strictly greater than 1.
Return the maximal possible number you can get at the end of this procedure. If it's not possible to perform k operations, return -1 instead.
|