Practice Minimum Possible Integer After at Most K Adjacent Swaps On Digits
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Hard#1505
LeetCode ProblemMinimum Possible Integer After at Most K Adjacent Swaps On Digits
Problem Statement
You are 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.
Source: Minimum Possible Integer After at Most K Adjacent Swaps On Digits on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
num = "4321", k = 4
Output
"1342"
# Example 2
Input
num = "100", k = 1
Output
"010"
# Example 3
Input
num = "36789", k = 1000
Output
"36789"
Constraints
1 <= num.length <= 3 * 10^4
num consists of only digits and does not contain leading zeros.
1 <= k <= 10^9
Related LeetCode Problems
Practice more problems similar to Minimum Possible Integer After at Most K Adjacent Swaps On Digits.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.