Search
⌘K

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

Given a digit string and a budget k of adjacent swaps, produce the lexicographically smallest string obtainable by performing at most k adjacent swaps. The core challenge is a greedy selection of the smallest digit that can be moved to each position within the remaining swap budget, which requires efficient tracking of positions/swaps (order-statistics) for large n and k.


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.