Class Solution
java.lang.Object
g1501_1600.s1505_minimum_possible_integer_after_at_most_k_adjacent_swaps_on_digits.Solution
1505 - Minimum Possible Integer After at Most K Adjacent Swaps On Digits.<p>Hard</p>
<p>You are given a string <code>num</code> representing <strong>the digits</strong> of a very large integer and an integer <code>k</code>. You are allowed to swap any two adjacent digits of the integer <strong>at most</strong> <code>k</code> times.</p>
<p>Return <em>the minimum integer you can obtain also as a string</em>.</p>
<p><strong>Example 1:</strong></p>
<p><img src="https://assets.leetcode.com/uploads/2020/06/17/q4_1.jpg" alt="" /></p>
<p><strong>Input:</strong> num = “4321”, k = 4</p>
<p><strong>Output:</strong> “1342”</p>
<p><strong>Explanation:</strong> The steps to obtain the minimum integer from 4321 with 4 adjacent swaps are shown.</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> num = “100”, k = 1</p>
<p><strong>Output:</strong> “010”</p>
<p><strong>Explanation:</strong> It’s ok for the output to have leading zeros, but the input is guaranteed not to have any leading zeros.</p>
<p><strong>Example 3:</strong></p>
<p><strong>Input:</strong> num = “36789”, k = 1000</p>
<p><strong>Output:</strong> “36789”</p>
<p><strong>Explanation:</strong> We can keep the number without any swaps.</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 <= num.length <= 3 * 10<sup>4</sup></code></li>
<li><code>num</code> consists of only <strong>digits</strong> and does not contain <strong>leading zeros</strong>.</li>
<li><code>1 <= k <= 10<sup>4</sup></code></li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
minInteger
-