1850. Minimum Adjacent Swaps to Reach the Kth Smallest Number
Medium
<ul> <li>The 1<sup>st</sup> smallest wonderful integer is <code>"5489355214"</code>.</li> <li>The 2<sup>nd</sup> smallest wonderful integer is <code>"5489355241"</code>.</li> <li>The 3<sup>rd</sup> smallest wonderful integer is <code>"5489355412"</code>.</li> <li>The 4<sup>th</sup> smallest wonderful integer is <code>"5489355421"</code>.</li> </ul> </li>
Input: num = "5489355142", k = 4
Output: 2
Explanation: The 4th smallest wonderful number is "5489355421". To get this number:
- Swap index 7 with index 8: "5489355142" -> "5489355412"
- Swap index 8 with index 9: "5489355412" -> "5489355421"Last updated