Given a number M (N-digit integer) and K-swap operations ,what is an algorithm to get the maximum possible integer?


  • 1
    S

    Given a number M (N-digit integer) and K-swap operations (a swap operation can swap 2 digits), what is an algorithm to get the maximum possible integer?

    Examples:

    1. M = 132, K = 1, output = 312
    2. M = 132, K = 2, output = 321
    3. M = 7899, K = 2, output = 9987
    4. M = 8799, K = 2, output = 9987

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.