1505. Minimum Possible Integer After at Most K Adjacent Swaps On Digits

https://leetcode.com/problems/minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits

Description

Given a string num representing the digits of a very large integer and an integer k.

You are allowed to swap any two adjacent digits of the integer at most k times.

Return the minimum integer you can obtain also as a string.

Example 1:

Example 2:

Example 3:

Example 4:

Example 5:

Constraints:

  • 1 <= num.length <= 30000

  • num contains digits only and doesn't have leading zeros.

  • 1 <= k <= 10^9

ac

Last updated

Was this helpful?